Re: Using SQL output in shell scripts

From: Jason Miller <millerjcr_at_hotmail.com>
Date: 7 Jan 2002 09:26:49 -0800
Message-ID: <9d5d63c7.0201070926.6d4b5b8f_at_posting.google.com>


"Comcast" <99baggett_at_home.com> wrote in message news:<Vz9_7.29496$LQ1.9579699_at_news2.nash1.tn.home.com>...
> What is the easiest way to use the output of a SQL statement in a shell
> script? I would like to be able to send an e-mail to tech support whenever
> the row count of a specific table exceeds a threshold value. Any help is
> appreciated.
>
> ...Mike

You can use sqlplus to get SQL output into a shell variable. For example:

COUNT=`sqlplus -silent $ORACLE_ID <<!EOF! set pagesize 0;
set feedback off;
set heading off;
select count(x)
from y
where z;
!EOF!` ORACLE_ID is set to the username/password. Received on Mon Jan 07 2002 - 18:26:49 CET

Original text of this message