Subject Re: [firebird-support] Exception in input file
Author Milan Babuskov
Mahesh Ishwar wrote:
> I'm giving an input file to execute some insert statements to isql. After some specified number of inserts I'm also using commit, just to be on safer side.
> But suppose, for any reason, if any of the insert statement fails, I want the sql file terminate its execution with data safe till the last commit.
> The behaviour I'm facing is that though the data is consistent till last commit, the file keeps on executing till it gets the last statement in the file, though most of the statements give some or other error becoz of the previous error in insert statement.
> Can I somehow stop executing the sql file since last error?

Not in isql.
You need to use some 3rd party software for this.

If it's just simple INSERT statements, you can write simple script (in
Perl, PHP, Python, C, whatever...) to do the job.

Just open the file, read until ; into buffer. Call isql with buffer as
input and see if it succeed (check isql return value). Repeat until the
end of file. This opens new connection every time, so it will last longer.

Other option is to use the tool of your choice, whatever you use anyway
(PHP, IBPP, IBObjects, IBX, etc...) to connect, parse the input file (;
is theseparator) and execute statements one by one (commiting every x lines)


Milan Babuskov