ON_ERROR_STOP
By default, if a script command results in an error, for example, because of a malformed command or invalid data format, processing continues. If you set ON_ERROR_STOP to ‘on’ in a script and an error occurs during processing, the script terminates immediately.
If you set ON_ERROR_STOP to ‘on’ in a script, run the script from Linux using vsql -f <filename>, and an error occurs, vsql returns an error code 3 to Linux to indicate that the error occurred in a script.
To enable ON_ERROR_STOP:
=> \set ON_ERROR_STOP on
To disable ON_ERROR_STOP:
=> \set ON_ERROR_STOP off