Operating System - Linux
1827889 Members
1782 Online
109969 Solutions
New Discussion

Re: shell script with sql

 
SOLVED
Go to solution
Unix or Linux?
Frequent Advisor

shell script with sql

I would like to issue some sql statements from within a shell script. Not sure how to go about it. Basically the shell script connects to the schema on the database and then should proceed with the select statements. But instead it just connects and stays with the SQL prompt. Hope it makes sense!
4 REPLIES 4
Sandman!
Honored Contributor

Re: shell script with sql

Could you post your script here so it can be looked at.

thanks!
Unix or Linux?
Frequent Advisor

Re: shell script with sql

ORACLE_SID="EM"; export ORACLE_SID
sqlplus user1/user1
select * from table1



It connects user1 to the database, but it does not run the select statement.
Patrick Wallek
Honored Contributor
Solution

Re: shell script with sql

Try this:

ORACLE_SID="EM"; export ORACLE_SID
sqlplus user1/user1 << EOF
select * from table1
exit
EOF
Unix or Linux?
Frequent Advisor

Re: shell script with sql

That did it. Thanks