Subject ISQL command line tools usage
Author t.s.
Dear All,

Recently i'm trying to create a set of a 'build script' to create a
blank database from scratch, using batch files and ISQL.EXE. At this
point, the structure of the script is something like this :

BUILD.BAT
-- create empty database
-- run script
isql.exe -i BUILD.sql -o output.sql -u xxx -p xxx

BUILD.SQL
input script\create_database.sql;
input script\create_view.sql;
input script\create_trigger.sql;
... blah blah blah x 100
input dummy_data\data_product.sql;
input dummy_data\data_something.sql;
... blah blah blah x 100

The thing is working to some extent, but a problem occurs when there are
tons of errors on script (for example, inserting 1000 of product record
that violates some integrity constraints). Piping the output to a text
file doesn't work, i.e.
BUILD.BAT >> capture.txt
will just generate a capture.txt with zero byte length.

After some digging, i found out in the IB6.x docs that there's a switch
for ISQL.EXE (-m or -merge) that will merge the output of stdout and
stderr into the file specified in the -o switch. After adding this
switch, i ended up with a big output.sql file, but at least the error
messages are there. I ended up using GREP to find instances of the
string 'SQLCODE', as most errors within the script returns this error code.

All is fine for a while.

Until i discovered that there are some errors that slipped through this
hack, namely if there's a line in the BUILD.SQL that references a
nonexistent file :
...
input script\missing_file.sql
...

The error returned is "unable to open 'missing_file.sql'", which i
wasn't expecting :). The other kind of errors that occured is when i
forgot to add a line break at the end of a script, isql will return
error that say "expected end of statement, blah blah".

So i suppose i'm not doing this right at all :). Any ideas of a better
way? I need the script to notify me of any errors it encountered while
running.

Thanks in advance.