Subject Re: Errorhandling in isql
Author rcrfb
--- In, Milan Babuskov <albis@e...>
> rcrfb wrote:
> > running FB 1.0.3 on Linux I need to execute a lot of
> > scripts using isql, sometimes also shell inline scripts
> > like
> > cat <<- EOT | isql .....
> > <statement>
> > <statement>
> > EOT
> >
> > Now my questions:
> > Is there any possibility to get the result of a sql statemetn
> > within the (sql) script out of 'isql'?
> I didn't quite undestand this one. Does -o switch help?

No, it won't.

I'm running some scripts as (shell-)inline as described above,
and some scripts immediately using 'isql .. -i file.sql ...'.

I need to run these scripts in batch mode and I only need an
exit status of the 'isql' command if any of the SQL statements
failed. Depending on that result the (batch-) script should do
different things.

> > Is there a possibility to exit the (sql) script depending on
> > the result (SQLCODE?) of the previous statement?
> No.
> > Is there an analogous command (for 'isql') like
> No.
> > I know, that
> > this is an Firebird-ESQL statement, but is there something
> > like that for 'isql'?
> No.
> I don't know what exactly you want to do, but I can guess.
> If you run scripts by hand, just enter the isql interactively, and then
> type:
> in first_sql_from_file.sql;
> in second_sql_file.sql;
> ...etc.
> If you use PHP you can write simple script that would do isql-like
> behavior, but you could add stuff like rollback on errors.

As I mentioned above, I'm doing (nightly) batch jobs using either
bash or ksh scripts. Within these scripts in need to do different
things in case one (or more) SQL statements fail, so I need the
result status of the isql command.

It will help me if the isql exists with failure status if any
sql statement fails. But it will be better if I could decide for
each statement which result code to return (depending on the SQLCODE
of the statement) or only do a rollback and continue with the
next sql statements.

> --
> Milan Babuskov