SQL*Plus User's Guide and Reference

Contents Index Home Previous Next

WHENEVER OSERROR

Purpose

Exits SQL*Plus if an operating system error occurs (such as a file I/O error).

Syntax

WHENEVER OSERROR {EXIT [SUCCESS|FAILURE|n|variable] [COMMIT|ROLLBACK]|CONTINUE [COMMIT|ROLLBACK|NONE]}

Terms and Clauses

Refer to the following list for a description of each term or clause:

EXIT [SUCCESS|FAILURE|n|variable] Directs SQL*Plus to exit as soon as an operating system error is detected. You can also specify that SQL*Plus return a success or failure code, the operating system failure code, or a number or variable of your choice. See EXIT in this chapter for details.
CONTINUE Turns off the EXIT option.
COMMIT Directs SQL*Plus to execute a COMMIT before exiting or continuing and save pending changes to the database.
ROLLBACK Directs SQL*Plus to execute a ROLLBACK before exiting or continuing and abandon pending changes to the database.
NONE Directs SQL*Plus to take no action before continuing.
Usage Notes

If you do not enter the WHENEVER OSERROR command, the default behavior of SQL*Plus is to continue and take no action when an operating system error occurs.

Examples

The commands in the following command file cause SQL*Plus to exit and COMMIT any pending changes if a failure occurs when writing to the output file:

WHENEVER OSERROR EXIT SQL.OSCODE COMMIT
SPOOL MYLOG
UPDATE EMP SET SAL = SAL*1.1
COPY TO SCOTT/TIGER@HQDB -
REPLACE EMP -
USING SELECT * FROM EMP
SPOOL OUT
SELECT SAL FROM EMP


Contents Index Home Previous Next