Stop on first error when running a (DB2) database script

Hello,

I was wondering if it is possible to stop executing a database script (DB2 in my case) as soon as an error occurs.
If I run an SQL script against my DB2 databse from within IntelliJ, the whole script is run, even if halfway some statements give errors. I would like the script to fail as soon as the first error occurs (which you get with the -s option when executing scripts from command line).

Does anyone know if this is currently possible? I couldn't find a way to do it.
If not, I'll file a bug for this to be implemented.

Thanks,

Guno

4 comments
Comment actions Permalink

Hello.

Latest builds 138.nnn do stop on the first error and suggest options: Retry, Ignore, Ignore All, Stop. What IDEA version do you have?

Regards,
Alexander.

0
Comment actions Permalink

I'm using latest EAP (138.1980.1).
Is there some setting that controls this behaviour?

It's easy to reproduce here. I've got file.sql in my project with the following contents:

SELECT 1 FROM SYSIBM.SYSDUMMY1;
INSERT INTO NonExistingTable(field) VALUES ('foo');
SELECT 2 FROM SYSIBM.SYSDUMMY1;


Right clicking the file and choosing Run "file.sql"... to run against my db2 database gives the following output:

[2014-09-11 21:17:04] Connecting to MyDB...
SELECT 1 FROM SYSIBM.SYSDUMMY1
[2014-09-11 21:17:04] Executed in 32 ms
INSERT INTO NonExistingTable(field) VALUES ('foo')
[2014-09-11 21:17:04] [42704][-204] "DB2INST1.NONEXISTINGTABLE" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.63.123
SELECT 2 FROM SYSIBM.SYSDUMMY1
[2014-09-11 21:17:04] Executed in 18 ms

[2014-09-11 21:17:04] Summary: 3 of 3 statements executed, 1 failed in 642 ms (110 chars in file)


As can be seen, the 2nd SELECT is executed, even though the INSERT failed. I would like it to stop right after the failed INSERT.

Greetings,
Guno

0
Comment actions Permalink

Thank you, got it. You're right: the advanced error reporting system works in the database console, but not supported when running an .sql file.

Please, take a look at the error reporting in database console: is that Ok? Then the request will be to support the same in .sql files. Or, maybe, some more functionality is required even in the console.

Regards,
Alexander.

0
Comment actions Permalink

The error reporting in database console looks ok, it'd be great if it works the same in sql files.

I've created a Youtrack issue for this:
http://youtrack.jetbrains.com/issue/IDEA-129793

Thanks!
Guno

0

Please sign in to leave a comment.