[ Oracle - Procedure 문법_EXCEPTION_020 ]

 

Error Handling

1. Predefined & Nonpredefined

Define

 Error번호

 exception_name

 

Predefined

 ORA_01403

 

ORA_01422

 NO_DATA_FOUND

 

TOO_MANY_ROWS

 

Nonpredefined

 ORA_02292

 e_products_remaining

 

2. Predefined Exception

 

  ex) EXCEPTION

        WHEN NO_DATA FOUND THEN

          v_message := TO_CHAR (v_product_id)||' Is invalid.';

        WHEN TOO_MANY_ROWS THEN

          v_message := 'Data corruption in S_PRODUCT';

        WHEN OTHERS THEN

          v_message := 'Other error occurred.';

        END;

 

3. NonPredefined Error

  

 exception EXCEPTION;

 ...

 

PRAGMA EXCEPTION_INIT (exception, error_number);

 

  ex) [DECLARE}

         e_products_remaining EXCEPTION;

       PRAGMA EXCEPTION_INIT (

         e_products_remaining, -2292);

         ...

       BEGIN

         ...

       EXCEPTION

       WHEN e_products_remaining THEN

          v_message := 'Referential integrity constraint violated.';

          ...

       END;

 

4. User_Defined Exception

 

exception EXCEPTION;

...

RAISE exception;

  ex) [DECLARE]

          e_amount-remaining EXCEPTION;

          ...

       BEGIN

          ...

       RAISE e_amount_remaining;

          ...

       EXCEPTION

       WHEN e_products_remaining THEN

         v_message := 'There is still an amount in stock.';

         ...

       END;

발주처:http://myhome.netsgo.com/mino70/main_03_oracle02.htm

Posted by 농부지기
,