0

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.

2 Answers 2

2

Or you could do:

SPOOL &1
SELECT...
SPOOL OFF

SQL> @C\MyFile.sql C:\Temp\File.csv
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.