Introduction PL/SQL

Basic PL/SQL

Advance PL/SQL

PL/SQL Built-in Exception



PL/SQL Errors are pe-defined and are automatically raised by Oracle whenever an error is encountered. Each error is assigned a unique number and a message.

PL/SQL, a warning or error condition is called an exception. Exceptions can be internally defined (by the run-time system) or user defined. Examples of internally defined exceptions include division by zero and out of memory. Some common internal exceptions have predefined names, such as ZERO_DIVIDE and STORAGE_ERROR. The other internal exceptions can be given names.

When an error occurs, an exception is raised. That is, normal execution stops and control transfers to the exception-handling part of your PL/SQL block or subprogram. Internal exceptions are raised implicitly (automatically) by the run-time system. User-defined exceptions must be raised explicitly by RAISE statements, which can also raise predefined exceptions.

To handle raised exceptions, you write separate routines called exception handlers.

Built-In Exception Syntax:

EXCEPTION
	WHEN <Buit-in Exception> THEN
		<User Defined Action to be taken>

Buit-In Example Code:

SQL>edit buitin_exp
DECLARE
	temp enum%rowtype;
BEGIN
	SELEC * INTO temp FROM enum
		WHERE eno=3;
EXCEPTION
	WHEN no_data_found THEN
		dbms_output.put_line('Table Does Not Data');
END;
/
SAVE: builtin_exp.sql

Buit-In Example Result:

SQL>@buitin_exp
Table Doen Not Data

Buit-in Exception List

  • "DUP_VAL_ON_INDEX
  • LOGIN_DENIED
  • NO_DATA_FOUND
  • NOT_LOGGED_ON
  • PROGRAM_EROOR
  • TIMEOUT_ON_RESOURCE
  • TOO_MANY_ROWS
  • VALUE_ERROR
  • OTHER