Using plsql, I want to run my test.sql multiple times, each time will pass in a different argument to test.sql and also spool that result to a different file.
The file name may not have a relation with the argument being passed.
I'm hoping I can define two 'arrays'; one for the filename to spool to, and the other for the argument value.
declare
my_types sys.dbms_debug_vc2coll := sys.dbms_debug_vc2coll('typeA', 'typeB', 'typeC');
my_filenames sys.dbms_debug_vc2coll := sys.dbms_debug_vc2coll('fileNameForA', 'fileNameForB', 'fileNameForC');
begin
for r in my_types.first..my_types.last
loop
--dbms_output.put_line(my_types(r));
--dbms_output.put_line(my_filenames(r));
spool my_filenames(r)
@test.sql my_types(r);
spool off
end loop;
end;
/
For the spool, it says that it encountered symbol "MY_FILENAMES" when it expected := . < @ % ;.
Also, it looks like test.sql is taking the argument I put in literally, so 'my_types(r)' instead of the expected 'typeA'. If there is a completely different and easier way of doing this in plsql then let me hear it. Thanks.
test.sql? What ismy_filenames? Where are you running this?spoolis a SQL*Plus command...test.sqlis just aselectstatement that uses the argument in thewhereclause.my_filenamesis a list of filenames to create when spooling. The first element inmy_filenamesshould be the file created for runningtest.sqlwith the argument being the first element inmy_types.spoolin PL/SQL. A PL/SQL block can generate files usingutl_filebut those files would exist on the database server not on the client.