Passing Parameters to a SQL Script

You can pass operating system parameters to SQL*Plus using this syntax:

sqlplus username/password @cmdfile.sql var1 var2 var3

Parameter var1 will be mapped to SQL*Plus variable &1, var2 to &2, etc.

Here’s an example:

sqlplus scott/tiger @test.sql '"test parameter"' dual

Where test.sql consists of:
select '&1' from &2;
exit 5;

Leave a Comment

Your email address will not be published. Required fields are marked *