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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass SQL in variable to SQLPlus instead of external file.

Status
Not open for further replies.

Wrathchild

Technical User
Aug 24, 2001
303
US
It seems using an external file to house the SQL is SOP for working with Oracle from a shell script. I have examples of this, but I'm trying to go a different route.

I was wondering if the SQL could just be in a variable and then pass that variable to the sqlplus command instead of referencing an external file? I'm using a Korn shell.

Something like:
export SQL
SQL="SELECT blah blah blah"
sqlplus -L -S user/password@db @ $SQL
 
Even in this forum ! faq822-2218

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi,

imho your answer is in the FAQ already mentioned.
Have a look at the use of Unix "|" symbol, e.g. in the very first example.

Details are left as an exercise to the reader ...
 
thanks guys, I just skipped over the "print" example because I was looking for something that began with "sqlplus..." - the print example worked fine
 
oh, and if anybody wants the final syntax I used:

export SQL
SQL="SELECT blah blah blah"
print $SQL | sqlplus -s user/password@db
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top