Predefined PL/SQL Exceptions
An internal exception is raised implicitly whenever your PL/SQL program violates an Oracle rule or exceeds a system-dependent limit. Every Oracle error has a number, but exceptions must be handled by name. So, PL/SQL predefines some common Oracle errors as exceptions. For example, PL/SQL raises the predefined exception
NO_DATA_FOUND
if a SELECT
INTO
statement returns no rows.
To handle other Oracle errors, you can use the
OTHERS
handler. The functions SQLCODE
and SQLERRM
are especially useful in the OTHERS
handler because they return the Oracle error code and message text. Alternatively, you can use the pragma EXCEPTION_INIT
to associate exception names with Oracle error codes.
PL/SQL declares predefined exceptions globally in package
STANDARD
, which defines the PL/SQL environment. So, you need not declare them yourself. You can write handlers for predefined exceptions using the names in the following list:
Brief descriptions of the predefined exceptions follow:
No hay comentarios:
Publicar un comentario