SQL Script: Stop Execution on First Error
Answered
When running a MySQL script within DG, it continues to execute after errors are reported. How can I get it to stop execution after the first error is encountered?
I am running DG 1.0.2 on Windows 7.
Please sign in to leave a comment.
Hello Michael,
There is File | Settings | Database | General -> Execute in Console settings exist, where you can choose execution policy when running the script. Also if there is a error executing the script there should be a error toolbar, where you can choose the action to Retry Ignore or Stop execution:
Doesn't it work for you?
Nope, no luck there. Here is what I see in that settings pane:
There is nothing in there pertaining to stopping on error. As you can see in this screenshot:
I put in a deliberate error, and it did flag it in the editor pane, but it kept on going and executed the rest of the script. Also, I do not get that red panel like you show in your screenshot.
Hope this helps show what I get.
Thank you for the screenshot. Looks like you are executing the script via Run <Script Name> action, which indeed executes the whole script as a batch. Please try using Ctrl(Cmd)Enter and select the script part to execute. If you want to execute the whole script you could select all and execute selection or adjust the options in File | Settings | Database | General.
That did the trick, many thanks! I changed the settings like you suggested, and now use Ctrl-Enter instead of Shift-Ctrl-Enter. The execution now stops on the error and gives me the option to continue or not.
Again, many, many thanks! :)
Hello, can I ask if the option to exit on first error would be available when executing scripts via `Run configuration`?
I have a series of script files to execute and doing it manually is tedious. Perhaps maybe it would be nice to atleast scramble the errors from the output console?
Thanks
Hello,
There is related request on YouTrack: https://youtrack.jetbrains.com/issue/DBE-16312/Cannot-stop-a-script-run-if-error-is-encountered
Please vote for it and follow for updates.