How can I stop a Postgres script when it encounters an error?

前端 未结 4 806
眼角桃花
眼角桃花 2020-12-13 11:34

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.

4条回答
  •  萌比男神i
    2020-12-13 12:12

    It's not exactly what you want, but if you start your script with begin transaction; and end with end transaction;, it will actually skip everything after the first error, and then it will rollback everything it did before the error.

提交回复
热议问题