pl/sql: dynamic sql, writing to file
492850Feb 24 2006 — edited Feb 24 2006I have a pl/sql procedure in which I dynamically generate a select statement (as a varchar2 v_my_query).
I now need to execute this query and write the results to a file using utl_file.
I can do 'execute immediate v_my_query', but how does this get the result to a file? Can I somehow get it into a cursor? The table name is a parameter to the procedure so I can't create the cursor up front.
I'm trying to do it all in one go - otherwise I'd write the v_my_query to a script and then run it from sqlPLUS with spool.
Any suggestions???