Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is it possible to use a shell script to login to a database (using SQLPLUS), run a query and assign the query result to a local variable defined in the shell?
I know it's possible to run SQLPLUS through a shell script if Oracle is installed on the machine but what I want to do is to assign a value to a variable while at the SQL prompt.
Thanks!

Yes thats verz well possible. Use sql execution in following manner.
sqlplus /nolog << END_SQL
connect $OPR_USER/$OPR_PASS
@db_changes.sql
exitEND_SQL
And you can put ur command in db_changes.sql which is generate in the script itself with all the variable values. Hope its not required to explain how u have to create this sql script.Or if u have to call one or two sql command then u can directly in between "connect $OPR_USER/$OPR_PASS" and exit .
trust this will help u . :)
Mukesh Kesharwani
CISSP, CCNA, SCSA,CUA,CNA, MCSE,MCP+I,CCNSE,Certified HIPPA Securityhttp://www.keekar.com

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |