Re: DBACCESS exit status
Posted in 1996
Steve Goldberg (goldberg@sccsi.com) wrote:
: All,
: I am dropping and creating tables in a database using dbaccess in a script.
: I need to test the result for a successful completion. I found that dbaccess
: returns a 255 on any error. If a table is not there and try to drop it (which
: is ok) I still get a 255. I am more concerned about dropping a table that
: fails because someone is in it (non-exclusive access). I need to stop the
: procedure at this point.
: Is there some other "env variable" that gets set besides $?. Is there a
: different "group" of numbers I can test?
: TIA,
: Steve Goldberg
: Landata RE-Source
: steveg@landata.com
Hi,
You can redirect stderr of dbaccess to stdout and try to catch errorcodes
you want to. For example:
dbaccess - - 2>&1 >logfile <<! | egrep '(error_code1|error_code2....)'
DATABASE some_database;
SELECT columns FROM some_table;!
or
error_code=`dbaccess some_database - 2>&1 <<! |\\
egrep '(error_code1|error_code2....)'
DROP TABLE tabname;!`
case $error_code in
.....
esac
You can add better error catching (egrep|sed etc.), it is just an example.
I hope this helps.
Regards,
Mirek
--
=================================
Miroslav Lorenc
Database Administrator
Software Applications and Systems Internet: Miroslav.Lorenc@sasprg.cz
Tiskarska 10/257
108 28 Prague 10 Tel: +42 2 705134
Czech Republic Fax: +42 2 705128