Tuesday, January 18, 2011

Oracle - PRAGMA EXCEPTION_INIT


PRAGMA EXCEPTION_INIT EXAMPLE:



DECLARE
   CNT NUMBER(2) := 0;
   EXCEP_NEW EXCEPTION;
   PRAGMA EXCEPTION_INIT(EXCEP_NEW,-06502);

BEGIN
    SELECT COUNT(*) INTO CNT FROM PER_ALL_PEOPLE_F;
   
   
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
       DBMS_OUTPUT.PUT_LINE('NO DATA FOUND');
    WHEN EXCEP_NEW THEN
        DBMS_OUTPUT.PUT_LINE('USER DEFINED EXCEPTION THROWN');
END;

No comments:

Post a Comment