Is there a way to specify that when executing a sql script it stops when encountering the first error on the script, it usually continues, regardless of previous errors.
Thanks
Is there a way to specify that when executing a sql script it stops when encountering the first error on the script, it usually continues, regardless of previous errors. Thanks |
|||
|
I think the solution to add following to .psqlrc is far from perfection
there exists much more simple and convenient way - use psql with parameter:
better to use also p.s. the solution found in great post from Peter Eisentraut. Thank you, Peter! http://petereisentraut.blogspot.com/2010/03/running-sql-scripts-with-psql.html |
|||||||||
|
I assume you are using
This will make it abort on the first error. If you don't have it, even with a transaction it will keep executing your script but fail on everything until the end of your script. And you probably want to use a transaction as Paul said. Which also can be done with So a complete example, with ON_ERROR_STOP in your .psqlrc:
|
|||||||||
|
It's not exactly what you want, but if you start your script with |
|||
|