Re: dbaccess fail status to Bourne shell exit status
Posted in 1999
Hi Stephen,
I don't think there's any easy way to get the status of the SQL
statement from an exit variable, but you could try the following:
dbaccess database sql_file 2> status.out
if [ -n `grep "Table dropped" status.out` ];then
status=OK
else
status=FAILED
cat status.out
mail -s"SQL problem" username < status.out
fi
The "table dropped" message (or the number of rows found for a query,
etc) is sent to stderr, so this can be easily re-directed to a file,
and then you can do whatever you like with it. Another possibility
would be to make use of cut to get the error number, run finderr, and
email the text of the error message to your account.
Hope this helps,
Richard
PS It's worth persevering with this way of running SQL statements -
very useful if like me you're not a programmer!!
On Tue, 20 Apr 1999 21:19:56 GMT, roach@NOSPAMportalinc.com (Stephen
Roach) wrote:
>Hi folks
>
>I want to invoke dbaccess through a Unix script and drop a table. If
>the table does not exist, I want the Unix script to report this using
>$?. dbaccess just executes a sql file with a single drop statement.
>Any ideas?
>
>TIA
>
>Steve
>
>---------------------------------------------------------
>Steve Roach: Remove NOSPAM from address to reply:
>steve_roach@NOSPAMibm.net
>steve_roach@NOSPAMhotmail.com