Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL*Plus & Parameters

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
I was wondering how to call a sql file in SQL*Plus with parameters. I have a batch file that runs sql plus and the file

sqlplus user/pass@db @f:\scripts\my_script.sql

Script my_script has several parameters (&param). When I run the script as above, I am prompt for my parameters, but I want to be able to hard code the parameters in the batch file. Some thing like

sqlplus user/pass@db @f:\scripts\my_script.sql &param1=blah &param2=blahblah

Is this possible? Does this make sense?

Thanks
 
In your batch file you would code your parameters as

[tt]sqlplus user/pass@db @f:\scripts\my_script.sql blah blahblah[/tt]

Then in the sql script you define the parameters like this

[tt]SELECT something
FROM a_table
WHERE col1 = '&1'
AND col2 = '&2';
[/tt]
 
You may also use &&1 to prevent further prompts for &1 value.

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top