Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Accessing a cursor using dynamic SQL
I am creating dynamic SQL, from the ALL_TAB_COLS table, and the output
is unknown until runtime. My SELECT statement may select 4 columns, 20
columns, or 200. Once I have built this SQL, how can I run it into a
cursor? How do I define that cursor?
It would be easy enough to do if I could get this to work, but evidently it does not, saying that it is finding LOOP when it is not expected.
FOR x IN (v_sql_stmt)
LOOP
IF x.variable_name THEN dbms_output.put_line(x.variable_name); END
IF;
END LOOP;
Using the OPEN-FETCH-CLOSE for cursors, how can I define the cursor
without knowing the structure of the output record? It seems the
%ROWTYPE is what I need, but that only works if you have a table to
reference. I would like to create the rowtype based on the out put
that my dynamic SQL would return. Any help or pointers would be
appreciated.
Mike Received on Tue Jul 25 2006 - 09:06:27 CDT