How to fetch record from Cursor and store them in memory -URGENT [message #37572] |
Thu, 14 February 2002 11:36 |
UmaSund
Messages: 22 Registered: February 2002
|
Junior Member |
|
|
Hi
My cursor is returning 9 rows of data. Now I need to grab the value from first row and store in memory, grab the second value and store in memeory.
Then i need to do calculation between the two stored value.
How do i store them in memory. The rows have no primary key.
A sample sample codeis greatly appreciated.
Thanks
-UmaSUND
|
|
|
|
|
Re: How to fetch record from Cursor and store them in memory -URGENT [message #37583 is a reply to message #37574] |
Thu, 14 February 2002 18:33 |
Somu
Messages: 24 Registered: February 2000
|
Junior Member |
|
|
Hi,
Try the following Sample Code.
create or replace procedure date1 is
wip_ent1 number(10);
oper_seq1 number(5);
lst_upd1 date;
qrc1 number(10);
wip_ent2 number(10);
oper_seq2 number(5);
lst_upd2 date;
qrc2 number(10);
date_dif number(5);
first1 number(1);
cursor c1 is select wip_entity_id,operation_seq_num,last_update_date,
qrc
from tab1;
begin
first1 := 1;
open c1;
loop
fetch c1 into wip_ent1, oper_seq1, lst_upd1, qrc1;
exit when c1%notfound ;
if first1 = 1 then
dbms_output.put_line('Entity Opr Seq No Days Diff QRC Date1
Date2');
dbms_output.put_line('===========================================================');
wip_ent2 := wip_ent1;
oper_seq2 := oper_seq1;
lst_upd2 := lst_upd1;
qrc2 := qrc1;
first1 := 0;
else
dbms_output.put_line(to_char(wip_ent2,'999999')||'
'||to_char(oper_seq2,'999999')||' '||to_char(trunc(lst_upd2 - lst_upd1),'9999')||'
'||to_char(qrc2,'9999')||' '||lst_upd2||' '||lst_upd1);
wip_ent2 := wip_ent1;
oper_seq2 := oper_seq1;
lst_upd2 := lst_upd1;
qrc2 := qrc1;
end if;
end loop;
end;
Sample Output.
----------------
Entity Opr Seq No Days Diff QRC Date1 Date2
===========================================================
1 1 1 10 04-FEB-02 03-FEB-02
1 1 2 20 03-FEB-02 01-FEB-02
2 3 0 22 01-FEB-02 01-FEB-02
2 4 2 25 01-FEB-02 30-JAN-02
2 4 10 26 30-JAN-02 20-JAN-02
|
|
|