I want to assign cursor variable in PL/SQL code and then fetch a row from that. When I declared cursor explicitly, it works.
DECLARE
cursor c1 is SELECT * from acme;
row1 c1%ROWTYPE;
but when I use code to assign cursor per e.g. Oracle PLSQL setting a cursor from a variable like that:
c1 sys_refcursor;
r1 c1%ROWTYPE;
I get error
the declaration of the type of this expression is incomplete or malformed
writting just r1 %ROWTYPE produces error too.
As per general use of variables explained e.g. here How to declare variable and use it in the same Oracle SQL script? I've tried:
SET SERVEROUTPUT ON
DECLARE
c1 sys_refcursor;
BEGIN
open c1 for 'SELECT * FROM foo';
declare r1 c1%ROWTYPE;
begin
fetch c1 into r1;
end;
DBMS_OUTPUT.PUT_LINE('FOO');
close c1;
END;
and again got the declaration of the type of this expression is incomplete or malformed
How can I declare variable of row type it my case? Oracle 11g.
P.S. workaround would be to fetch c1 into v_empno, v_ename, ect declaring several variables, still, is there a way to use rowtype one?