Writing out the results from a query back to a file.

Writing out the results from a query back to a file.

 

  

Hi,
 
I'm stuck and need some help.
 
Here is the scenario.
 
I have a text file that contains various SQL statements.
 
I want a Stored Procedure that will
 
*         take the file name as  a parameter
*         read the file
*         identify each SQL statement in the file
*         run each statement
*         return the results from the statement to a flat file.
 
So far I have written a SP that will read the file into an array, identify each  SQL statement and rebuild each statement ready for execution.
 
I'm having problems actually running the SQL statement and writing out the results to a file.  I can't use an array to store the results because I don't know the number/type of columns until I have built the SQL read in and rebuilt the SQL statement.
 
Does anyone have any ideas on this one?
 
I've started to look at using the dbms_sql package but still trying to get my head around what it can do and if it will help me.
 
All your help is gratefully received........  and a welcome headache tablet.
 
Marcus Wilkinson
 
 

Oracle LazyDBA home page