Hi,

I have a procedure(proc1) which does some insert operations and at last calls another procedure(proc2). Proc2 has a select statement which is declared in a cursor with return for. Now when I call proc1 I want it to do all the inserts which is specified in its block and display the result fetched by proc2 which is internally called by proc1.


How can I do that??

I have created both the procedures and they are working fine. When I call Proc1 it simply writes executed successfully and the when I check in the table the data is inserted but how can the data fetched by the select statement in proc2 be dislpayed when I call proc1??

Here are the procedures

PROC1 :

CREATE OR REPLACE PROCEDURE ACHINST1.ReportD010 ( IN MISDATE date, IN start_date DATE, IN end_date DATE, IN sender_name varchar (50) )
SPECIFIC ReportD010
LANGUAGE SQL
NOT DETERMINISTIC
EXTERNAL ACTION
MODIFIES SQL DATA
OLD SAVEPOINT LEVEL
begin

declare increment_date date;
declare last_date date;
declare expairy_date date;
if (start_date is null and end_date is null)
then
set increment_date = misdate;
set last_date = misdate;
else
set increment_date = start_date;
set last_date = end_date;
end if;
Repeat
set expairy_date = achinst1.aging (increment_date, (select valuestring from achinst1.systemparameter where sp_key = 'NO_DAYS_CONSIDERED_AS_ACCEPTED'));
insert into achinst1.tat_table values (increment_date, expairy_date);
set increment_date = increment_date + 1 days;
until (increment_date > last_date)
end repeat;
call achinst1.test (misdate,start_date,end_date, sender_name);
end;

PROC2:

CREATE OR REPLACE PROCEDURE ACHINST1.test ( IN MISDATE date, IN start_date DATE, IN end_date DATE, sender_name varchar (50) )
SPECIFIC test
LANGUAGE SQL
NOT DETERMINISTIC
EXTERNAL ACTION
MODIFIES SQL DATA
OLD SAVEPOINT LEVEL
begin

DECLARE C1 CURSOR WITH RETURN FOR

select * from (
SELECT COALESCE(MISDATE,START_DATE,to_date('01-'||month(current date)||'-'||year(current date),'DD-MM-YYYY')) as START_DATE,
COALESCE(MISDATE,END_DATE,LAST_DAY(current date)) as END_DATE,d.disputekey ,d.creationdate ,t.expairy_date,date(max(a1.timestamp)) as businessdate, p.name as SENDERNAME,p1.name as RECEIVERNAME,d.trandate,
d.tranrefnumber,a.amount,(case when d.disputetype = '1' then 'Initial Dispute'
when d.disputetype = '2' then 'Pre-Arbitration Dispute'
when d.disputetype = '3' then 'Good Faith Dispute'

end ) as disputeType,d.disputestatus from achinst1.dm_dispute as d
inner join achinst1.achiteminfo as a on a.id = d.DISPUTEDACHITEM_ID
inner join achinst1.participant as p on SENDERPARTICIPANT_ID = p.id
inner join achinst1.participant as p1 on RECEIVERPARTICIPANT_ID = p1.id
left outer join ACHINST1.AUDITENTRY as a1 on a1.OBJECTID=d.id
left outer join achinst1.tat_table as T on d.creationdate = T.current_date
where d.disputestatus='REJECT'
group by d.disputekey,d.creationdate,t.expairy_date,p.name ,p1.name,d.trandate,
d.tranrefnumber,a.amount,d.disputestatus ,case when d.disputetype = '1' then 'Initial Dispute'
when d.disputetype = '2' then 'Pre-Arbitration Dispute'
when d.disputetype = '3' then 'Good Faith Dispute'
end
order by date(max(a1.timestamp)),d.creationdate,p.name,p1.n ame,d.disputekey

)
where businessdate between coalesce(MISDATE,START_DATE,to_date('01-'||month(current date)||'-'||year(current date),'DD-MM-YYYY'))
and coalesce(MISDATE,END_DATE,LAST_DAY(current date)) and SENDERNAME like nvl(SENDER_NAME,'%') ;

open C1;
delete from achinst1.tat_table;
end;