Christopher,

I'm not a ksh expert, but this works for me.

#!/bin/ksh
count=$($ORACLE_HOME/bin/sqlplus -s user/password << EOF
set wrap off
set feedback off
set pagesize 0
set verify off
SELECT count(*) from arschema
/
exit
EOF
)

echo $count 





HTH

Kind Regards Conny


-----Ursprüngliche Nachricht-----
Von: Action Request System discussion list(ARSList) 
[mailto:arsl...@arslist.org] Im Auftrag von Pruitt, Christopher (Bank of 
America Account)
Gesendet: Freitag, 23. April 2010 21:52
An: arslist@ARSLIST.ORG
Betreff: 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
christopher.pru...@hp.com
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"

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

Reply via email to