I have written a simple stored procedure in PL/SQL to perform the equivalent of
SELECT * FROM tablename
Here is the procedure that returns a reference cursor
create or replace
procedure proc_name (outVal OUT sys_refcursor) as
myCursor sys_refcursor;
myRecords records%ROWTYPE;
l_sql VARCHAR(2000);
begin
l_sql := 'SELECT * FROM RECORDS';
open myCursor for l_sql;
loop
FETCH myCursor INTO myRecords;
EXIT WHEN myCursor%NOTFOUND;
"DBMS_OUTPUT.put_line('myRecords.name =' || myRecords.name);"
end loop;
close myCursor;
end;
Now when i want to execute my procedure in the SQL Command Prompt without including the line in quotes in my code , I go about doing it this way
VARIABLE cr REFCURSOR
EXEC proc_name(:cr)
Now i get a prompt saying
PL/SQL procedure successfully completed
Now when i try executing the command
print cr;
I get an error
ORA-24338: Statement handle not executed
Please help me with this . I need to know how to print the table using just this reference cursor returned by my stored procedure . I do not want to print anything within the procedure itself and hence want to remove the line in quotes from the procedure all together .