Re: Using SQL output in shell scripts

From: tonya <tntburgess_at_aol.com>
Date: 7 Jan 2002 11:30:25 -0800
Message-ID: <bd4ec694.0201071130.2c7ad28c_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

Mike,

If this is an oracle database, you can use the utl_file parameter to generate the output from the sql statement. Basically you could do the following:
1. Set the utl_file parameter in the init.ora file (you must reboot the instance in order for it to work). Basically, utl_file allows you to generate output files from pl/sql scripts. 2. Create a shell script which checks for the threshold value ( the check would be your select statement). Within the shell script, if the threshold value is exceeded, use utl_file to create an output file which contains the output of the sql statement. 3. You can use the output file generated from the shell script via utl_file to send to your tech support.

otn.oracle.com has a news group where people provided pl/sql scripts which uses the utl_file parameter.

I hope this helps ...

good luck. Received on Mon Jan 07 2002 - 20:30:25 CET

Original text of this message