PL/SQL Exceptions  «Prev 

How to code Predefined Server Exceptions

How to code predefined server exceptions
EXCEPTION
  WHEN cursor_name THEN
    statement_1,...,statement_n
  WHEN OTHERS
    statement_l1,...,statement_m
How to code predefined server exceptions

cursor_name
A predefined server cursor
statement_1,...,statement_n
A sequence of statements
statement_11,...,statement_n
A sequence of statements
SELECT PRODUCT_NAME INTO v_prod_name FROM PRODUCT WHERE PRODUCT_ID = 24;
This might cause a 'No data found' error if there is no product with a product ID of 24 in the product table
EXCEPTION
Exception handlers begin here
WHEN NO_DATA_FOUND THEN
Handles the 'No data found' error
WHEN OTHERS THEN
Handles all other errors