Accessing SQL session from UNIX shell script [message #127816] |
Wed, 13 July 2005 09:08 |
pravisri
Messages: 10 Registered: March 2005 Location: Manchester
|
Junior Member |
|
|
I am writing a UNIX script to execute some SQL and PL/SQL blocks sequentially by passing parameters into the UNIX script. One of my parameters is Oracle database userid/password and the database schema name. The passed parameter will be somewhat like this cnc/cnc@nexp; How can I check from the UNIX script whether the passed parameters are correct ?
Many Thanks & Kind Regards
Srinivas
|
|
|
|
|
Re: Accessing SQL session from UNIX shell script [message #128018 is a reply to message #128000] |
Thu, 14 July 2005 11:02 |
oralew
Messages: 4 Registered: July 2005
|
Junior Member |
|
|
I do it by checking the posix return from the sqlplus connection command in the script e.g.
#!/bin/ksh
sqlplus -s user/password@schema << EOF > /dev/null
select count (*) from table
/
exit
EOF
echo "SQL status was $?\n"
###########################################
When testing if I enter an incorrect user or password the exit status is 1 as opposed to exit status of 0 if correct user and password are used. A simple test in the script can then tell you if the params were correct. Any help?
|
|
|
|
|