Reputation: 195
What I'd like to do is parameterize the SPOOL path "C:\" so that in command line I can pass a path.
Sample script MyFile.sql:
SPOOL "C:\Temp\File.csv" --How do I parameterize this?
SELECT Column FROM Table
SPOOL OFF
CommandLine: SQL> @C\MyFile.sql --Would like to pass in a path here.
Upvotes: 0
Views: 1138
Reputation: 43523
Or you could do:
SPOOL &1
SELECT...
SPOOL OFF
SQL> @C\MyFile.sql C:\Temp\File.csv
Upvotes: 2
Reputation: 89
The easiest way i can think of would be to call sqlplus from a .bat file that takes as input the parameter, writes out a primary SQL script which contains the spool + the parameter and then calls your actual script.
You would get an extra @secondary_script_name.sql at the beginning of output though.
Upvotes: 1