How to move columns in oracle pl / sql cursor

I am creating a dynamic cursor, and I would like to iterate over the columns existing in the cursor. How can I do it?

For instance:

create or replace procedure dynamic_cursor(empid in varchar2, RC IN OUT sys_refcursor) as stmt varchar2(100); begin stmt := 'select * from employees where id = ' || empid; open RC for stmt using val; for each {{COLUMN OR SOMETHING}} --TODO: Get this to work loop; end; 
+2
source share
1 answer

You will need to use Oracle Dynamic SQL , most likely method 4 .

EDIT: Sorry, above for Pro * C. You will need to use the DBMS_SQL package. This is quite complicated, but it will allow you to parse, execute, and retrieve any arbitrary SQL query you need at runtime. In particular, take a look at examples 3 and 8.

+3
source

All Articles