Advanced Oracle PL/SQL Programming with Packages

Advanced Oracle PL/SQL Programming with PackagesSearch this book
Previous: 5.9 PLVdyn: Dynamic SQL OperationsChapter 5
PL/Vision Package Specifications
Next: 5.11 PLVfile: Operating System I/O Manager
 

5.10 PLVexc: Exception Handling

The PLVexc (PL/Vision EXCeption handling) package provides generic and powerful exception-handling capabilities. See Chapter 22, Exception Handling for details.

5.10.1 Package constants

c_go CONSTANT CHAR(1) := 'C';

Requests that your program continue (ignore the error). Explained in more detail below.

c_recNgo CONSTANT CHAR(2) := 'RC';

Requests that your program record the error and then continue. Explained in more detail below.

c_stop CONSTANT CHAR(1) := 'H';

Requests that your program be halted if this exception occurs. Explained in more detail below.

c_recNstop CONSTANT CHAR(2) := 'RH';

Requests that your program record the error and then halt. Explained in more detail below.

5.10.2 Package-based exceptions

process_halted EXCEPTION;

Package-specific exception raised when you request a "halt" action in the handler programs.

no_such_table EXCEPTION;
PRAGMA EXCEPTION_INIT (no_such_table, -942);

Predefined system exception for error ORA-942. Saves other developers from dealing with the EXCEPTION_INIT pragma.

snapshot_too_old EXCEPTION;
PRAGMA EXCEPTION_INIT (snapshot_too_old, -1555);

Predefined system exception for error ORA-1555. Saves other developers from dealing with the EXCEPTION_INIT pragma.

5.10.3 Logging exception-handling activity

PROCEDURE log;

Requests that whenever a PLVexc handler is called, a message is sent to the PL/Vision log.

PROCEDURE nolog;

Do not log the handling action when the exception is recorded and handled. with the COMMIT.

FUNCTION logging RETURN BOOLEAN;

Returns TRUE if currently logging PLVexc-based exception handling.

5.10.4 Displaying exceptions

PROCEDURE show;

Requests that error information be displayed to your screen using the p.l procedure.

PROCEDURE noshow;

Turns off display of the error information.

FUNCTION showing RETURN BOOLEAN;

Returns TRUE if PLVexc is currently showing errors.

5.10.5 Rolling back on exception

PROCEDURE rblast;

Requests that a rollback be issued to the most recent savepoint before writing error information to the log (the default).

PROCEDURE rbdef;

Requests that a rollback be issued to the default PLVlog savepoint before writing error information to the log (the default).

PROCEDURE norb;

Turns off issuing of rollback before logging of the error information.

FUNCTION rb RETURN VARCHAR2;

Returns TRUE if PLVexc is currently issuing a rollback.

5.10.6 Exception handlers

PROCEDURE handle
(context_in IN VARCHAR2,
err_code_in IN INTEGER,
handle_action_in IN VARCHAR2,
msg_in IN VARCHAR2 := SQLERRM);

Low-level, generic exception-handling program. This program is called by all other PLVexc handlers, which are overloaded for error number and message.

PROCEDURE recNgo (msg_in IN VARCHAR2 := NULL);
PROCEDURE recNgo (err_code_in IN INTEGER);

High-level exception handler that records and then ignores the error.

PROCEDURE go (msg_in IN VARCHAR2 := NULL);
PROCEDURE go (err_code_in IN INTEGER);

High-level exception handler that ignores the error, but gives you the opportunity to log or display the exception.

PROCEDURE recNstop (msg_in IN VARCHAR2 := NULL);
PROCEDURE recNstop (err_code_in IN INTEGER);

High-level exception handler that records the error and then causes the current program to halt.

PROCEDURE stop (msg_in IN VARCHAR2 := NULL);
PROCEDURE stop (err_code_in IN INTEGER);

High-level exception handler that causes the current program to halt.

5.10.7 Bailing out program execution

PROCEDURE bailout;

Starts the bailout process; the current exception will be propagated out of all exception sections that use PLVexc, regardless of the action handled.

PROCEDURE nobailout;

Turns off the bailout process. PLVexc will not propagate the exception past all PLVexc exception handlers.

FUNCTION bailing_out RETURN BOOLEAN;

Returns TRUE if PLVexc is currently set to bail out when it encounters a bailout error.

PROCEDURE clear_bailouts;

Registers a specific error number as a bailout error.

5.10.8 Managing the list of bailout errors

PROCEDURE clear_bailouts;

Clears the PLVexc list of bailout errors.

PROCEDURE bailout_on (err_code_in IN INTEGER);

Adds an error code to the list that PLVexc treats as bailout errors.

PROCEDURE nobailout_on (err_code_in IN INTEGER);

Removes an error code from the list that PLVexc treats as bailout errors.

FUNCTION bailout_error (err_code_in IN INTEGER) RETURN BOOLEAN;

Returns TRUE if the specified error is a bailout error.


Previous: 5.9 PLVdyn: Dynamic SQL OperationsAdvanced Oracle PL/SQL Programming with PackagesNext: 5.11 PLVfile: Operating System I/O Manager
5.9 PLVdyn: Dynamic SQL OperationsBook Index5.11 PLVfile: Operating System I/O Manager

The Oracle Library Navigation

Copyright (c) 2000 O'Reilly & Associates. All rights reserved.

Library Home Oracle PL/SQL Programming, 2nd. Ed. Guide to Oracle 8i Features Oracle Built-in Packages Advanced PL/SQL Programming with Packages Oracle Web Applications Oracle PL/SQL Language Pocket Reference Oracle PL/SQL Built-ins Pocket Reference