Tuesday, 11 October 2011

Exceptions (User-DefinedOracle Defined)

{\rtf1\ansi\ansicpg1252\deff0\deflang16393{\fonttbl{\f0\froman\fprq2\fcharset0 Times New Roman;}{\f1\fnil\fcharset0 Calibri;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\li1440\cf1\lang1033\f0\fs22 Oracle includes about 20 predefined exceptions (errors) - we can allow Oracle to raise these implicitly. For errors that don't fall into the predefined categories - declare in advance and allow oracle to raise an exception. For problems that are not recognized as an error by Oracle - but still cause some difficulty within your application - declare a User Defined Error and raise it explicitly\par
\cf0 Trap non-predefined errors by declaring them. You can also associate the error no. with a name so that you can write a specific handler. This is done with the PRAGMA EXCEPION_INIT pragma. PRAGMA (pseudo instructions) indicates that an item is a 'compiler directive' running this has no immediate effect but causes all subsequent references to the exception name to be interpreted as the associated Oracle Error. When an exception occurs you can identify the associated error code/message with two supplied functions SQLCODE and SQLERRM.\par
Trapping user-defined exceptions\par
\par
DECLARE the exception\par
RAISE the exception\par
Handle the raised exception\par
\par
Propagation of Exception handling in sub blocks\par
If a sub block does not have a handler for a particular error it will propagate to the enclosing block - where more general exception handlers can catch it.\par
\par
RAISE_APPLICATION_ERROR (error_no, message [, \{TRUE|FALSE\}]);\par
\par
This procedure allows user defined error messages from stored sub programs - call only from stored sub prog.\par
Error_no = a user defined no (between -20000 and -20999)\par
\par
TRUE = stack errors\par
FALSE = keep just last\par
\par
This can either be used in the executable section of code or the exception section\par
\pard\sa200\sl276\slmult1\lang9\f1\par
}

No comments:

Post a Comment