$? references the exit code for the application.  Normally, a non-zero exit 
code indicates an error, so I'm wondering if that's really the output of 
sqlplus.  Are you sure that it's exit code equals the number returned from the 
select statement, rather than, say, printing the results out on stdout?  If 
it's writing the output to stdout, then you will need to execute sqlplus 
differently so that it assigns the output to the variable.  For example, I 
think syntax similar to this may do it:

x = `someprogram args`

or

x = ${someprogram args}

Otherwise, I'm wondering about the quotes around your assignment statement.  I 
would expect not to have quotes there.  I would expect something more like this:

RESULTS = $?

Then again, I'm more of a BASH person than KSH, and KSH is a bit special...

Lyle

-----Original Message-----
From: Action Request System discussion list(ARSList) 
[mailto:[email protected]] On Behalf Of Pruitt, Christopher (Bank of America 
Account)
Sent: Friday, April 23, 2010 1:52 PM
To: [email protected]
Subject: Any ksh shell experts on the list?

Are there any KSH shell experts on the list or can you point me to some. I am 
at my wits end. 

I have a script that monitors a Remedy table in Oracle and does a count of 
records in that table. The select statement brings back a count but what I 
can't seem to get the sqlplus to do is return the results of the select 
statement back to a variable in the script. The reason I need it to return the 
results of the count statement is to then test it in an If statement. Below is 
an example of what I have tried.

I have tried some many different approaches to this and none seem to work. Has 
anyone on here done something like this before?


#------------- Oracle SQL -------------------------

sqlplus -S $user/$pass <<EOF
select count(*)
from aradmin.monitor_table;
EXIT
EOF
let "RESULTS = $?"


#------------- If Statement -------------------------

if [ $RESULTS -gt 10 && $RESULTS -lt 150 ];
then
echo    'SUCCESS'
fi


Christopher Pruitt 
Business Consulting III 
HP Enterprises Services
[email protected]
www.hp.com 


Confidentiality Notice: This message and any files transmitted with it are 
intended for the sole use of the entity or individual to whom it is addressed, 
and may contain information that is confidential, privileged, and exempt from 
disclosure under applicable law. If you are not the intended addressee for this 
e-mail, you are hereby notified that any copying, distribution, or 
dissemination of this e-mail is strictly prohibited. If you have received this 
e-mail in error, please immediately destroy, erase, or discard this message. 
Please notify the sender immediately by return e-mail if you have received this 
e-mail by mistake.

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug10 www.wwrug.com ARSlist: "Where the Answers Are"


 NOTICE: This email message is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not the 
intended recipient, please contact the sender by reply email and destroy all 
copies of the original message.

_______________________________________________________________________________
UNSUBSCRIBE or access ARSlist Archives at www.arslist.org
attend wwrug10 www.wwrug.com ARSlist: "Where the Answers Are"

Reply via email to