Re: cursor in cursor
Date: Sat, 2 Jun 2001 12:03:19 +0200
Message-ID: <9fadd4$51l87$1_at_reader03.wxs.nl>
Try this:
declare
cursor c_temp (b_id in pls_integer)
is select 'X'||to_char(b_id) test , b_id test_id from dual where b_id is not null
;
cursor c_temp2(b_id in pls_integer)
is select 'Y'||to_char(b_id) test from dual where b_id is not null
;
r_temp c_temp%rowtype; r_temp2 c_temp2%rowtype; l_id pls_integer;
begin
for l_id in 1..10 loop
open c_temp(b_id => l_id); fetch c_temp into r_temp; if c_temp%found then dbms_output.put_line(r_temp.test); open c_temp2(b_id => r_temp.test_id); fetch c_temp2 into r_temp2; if c_temp2%found then dbms_output.put_line(r_temp2.test); end if; close c_temp2; end if; close c_temp;
end loop;
end;
/
Ananth <apolepally_at_att.com> schreef in berichtnieuws
a04d60e3.0106010821.14844b6d_at_posting.google.com...
> I am trying to impliment a cursor in cursor.
> I have declared both of them together and fetching the second one for
> every cursor row of the first one.
> oracle is not able to recognize the second cursor.
> Can anybody shed some light on this..an example would be great
> =========================
> DECLARE
>
> CURSOR1;
> CURSOR2
>
> BEGIN
>
> OPEN CURSOR1
> LOOP (1)
> FETCH CURSOR1
> OPEN CURSOR2
> LOOP (2)
> FETCH CURSOR2
> --
> --
> END LOOP(2)
> CLOSE CURSOR2
> END LOOP(1)
> CLOSE CURSOR1
>
> END;
> ========================
Received on Sat Jun 02 2001 - 12:03:19 CEST