SQLERROR is not a DML or DDL statement but a scripting command understood by Oracle SQL*Plus and Oracle SQLcl. It is used in the form WHENEVER SQLERROR to set an error-handling policy for the remainder of a script. After each SQL or PL/SQL statement, SQL*Plus checks the SQLCODE. If it is non-zero, SQLERROR triggers the action specified (EXIT or CONTINUE) and optionally issues a COMMIT or ROLLBACK.With EXIT, SQL*Plus terminates and returns a status code to the operating system, letting calling shells or CI jobs detect failure. With CONTINUE, the script keeps running. You can supply an explicit numeric return code, a bind variable, or the keywords SUCCESS/FAILURE. COMMIT or ROLLBACK decides what to do with the current transaction before exiting or continuing. Because SQLERROR is evaluated on the client side, it does not affect database transaction semantics beyond the optional commit or rollback.SQLERROR is frequently paired with WHENEVER OSERROR, which handles operating-system errors (for example, failure to spool a file). Together they allow robust, automation-friendly SQL*Plus scripts. Other tools (psql, mysql, sqlcmd) do not support SQLERROR, so attempting to run these commands outside Oracle SQL*Plus will raise a syntax error.
EXIT
- Tells SQL*Plus to terminate when an error occurs.CONTINUE
- Tells SQL*Plus to keep running after an error.SUCCESS
(FAILURE) - Return 0 (success) or 1 (failure) to the OS.bind_variable
- Exit status taken from a numeric bind variable.COMMIT
- Commit pending changes before exiting/continuing.ROLLBACK
- Roll back pending changes before exiting/continuing.NONE
- Do nothing to the transaction before continuing (CONTINUE only).WHENEVER OSERROR, SQLCODE, SQLERRM, EXCEPTION handling, COMMIT, ROLLBACK
Oracle SQL*Plus 1.0
EXIT stops the script and returns a status code to the operating system, while CONTINUE lets the script keep running after logging the error.
No. The directive is interpreted by SQL*Plus before sending statements to the database. For in-procedure handling, use PL/SQL EXCEPTION blocks.
Specify a numeric value or a bind variable after EXIT. Example: `WHENEVER SQLERROR EXIT 42` returns 42 to the shell on failure.
SQL*Plus leaves the transaction open. Exiting without an explicit COMMIT or ROLLBACK usually results in an implicit rollback on the server side.