Capturing SQL O/P in Unix Script

Hi,

I would like to run a job based on the output from the SQL output.
Eg: Select count() from A ...if count() = 1 then execute the next step or else exit.

Please advise.

Thanks

S

echo "
set pages 0
set feed off
select count(*) from mytable;
exit
" | sqlplus -s username/pwd@dbname | tr -d '[:space:]' | read value
if [[ $value -eq 1 ]] ; then
  # do something
fi

Thank you for your immediate response. I will try it and update the post.

:slight_smile: