Home » SQL & PL/SQL » SQL & PL/SQL » Getting Values from a Record Variable into a Cursor Variable
Getting Values from a Record Variable into a Cursor Variable [message #37938] Thu, 07 March 2002 10:15 Go to next message
bwilliam
Messages: 2
Registered: March 2002
Junior Member
Thanks in advance for your help..
Using Oracle PL/SQL for 8i:
If I have a reference cursor variable (c) that is based on a certain Record Type. I can create a record variable that is the same record type and then FETCH data from the cursor into the Record Type variable. No problem.

However, what I need to know is whether there is a way to go the other way and put the values that are in a record variable into a cursor variable.

I tried things like:

OPEN c FOR
SELECT
vRecTemp
FROM Dual; where vRecTemp is the record variable that I am trying to get into the cursor.

But this causes an error of invalid datatype.

Any ideas on how I can get this data into the cursor?

Thanks
Re: Getting Values from a Record Variable into a Cursor Variable [message #37943 is a reply to message #37938] Thu, 07 March 2002 10:47 Go to previous message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
selecting record variable is not allowed.but you can open cursor for individual elements in record..

look at this example:

declare
type r is record ( x number,y varchar2(20));
type c1 is ref cursor;
r1 r;
r2 r;
c c1;
n number:=0;
begin
r1.x :=0;
r1.y :='Oracle';
open c for select r1.x,r1.y from dual;
loop
fetch c into r2;
exit when c%notfound;
dbms_output.put_line(r2.x||' '||r2.y);
end loop;
close c;
end;
Previous Topic: Dual table query
Next Topic: is this possible
Goto Forum:
  


Current Time: Wed Oct 27 04:42:18 CDT 2021