In a csh script, can I set a variable to the result of an SQLPLUS select query?

Can someone tell me why I'm getting [unmatched `] error when I try to run this?

#!/bin/csh -f
source ~/.cshrc
#
set SQLPLUS = ${ORACLE_HOME}/bin/sqlplus
#
set count=`$SQLPLUS -s ${DB_LOGIN} << END
select count(1) from put_groups where group_name='PC' and description='EOD_EVENT' and serial_number=1;
exit;
END`
#
if [$count < 1] then
echo "ERROR: EOD message for PC not found"
endif
#######

If I remove the "set count =" portion and just have the SQLPLUS run, it does retreieve a count. why can't I set that number to my count variable?

thanks!!

Or can I only do this type of variable setting using bash or some other shell?

hmmm thats because you are entering more than one line inside "`"

 
set count=`$SQLPLUS -s ${DB_LOGIN} << END\
set head off;\
select count(1) from put_groups where group_name='PC' and description='EOD_EVENT' and serial_number=1;\
exit;\
END`

So you're saying if I run it all together into one really long line, it should work? I tried that just now and got a "badly placed ()'s error" - something different though! Would you mind posting it the way you feel it should appear in my .csh ? Thank you!!

shouldn't count(1) be count(*) ?
i get a syntax error with count(1) within SQL.

just type the way i written.. above
at the end of line place "\" to continue with the command

count(1) ,count() and count(ROWNUM) mean same but count(1) runs faster than count()

THANK YOU!!!! It's working. You're a life-saver.