I written a code to return set of records as below
CREATE PROCEDURE test (from_dt date, to_dt date, out sys_refcursor)
as
cursor c
is
select max(cde)
from table1
where to_char(dt, 'yyyymmdd') between from_dt and to_dt
group by id;
begin
for i in c
loop
select function(i.cde) into v_cde from dual;
open out for select column1, v_cde, column2, column2 from table2
where to_char(dt, 'yyyymmdd') between from_dt and to_dt;
end loop;
end;
After execute the above procedure all records are retruned correctly except v_cde
function return value. It returns same value for all records.
I think cde
value is not went under looping.
How can i use function along with ref_cursor in loop?.
I anyone have suggestions, tell me.
table1
andtable2
related? Why does your cursorc
not select theid
column fromtable1
? It gives you a bunch of max values ofcde
, grouped byid
, without telling you whichid
each max value corresponds to. Also, your parameter namedout
is anIN
parameter: if you want to return it from your proc, you have to declare itout out sys_refcursor
.