Exception and Handler

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ricci
    New Member
    • Sep 2011
    • 1

    Exception and Handler

    I've trying to make a SP which could catch a SQL error and catch anothers exception, but if I use Exception when I declare the handler it send me an error, the code is:

    CREATE PROCEDURE prueba (equery IN NUMBER)
    IS
    exception1 EXCEPTION;
    exception2 EXCEPTION;
    PRAGMA EXCEPTION_INIT( exception2,-942);
    ecode INTEGER DEFAULT 0;
    SQLCODE INTEGER DEFAULT 0;
    CONTINUE HANDLER FOR SQLEXCEPTION;
    BEGIN

    SET (ecode = SQLCODE);

    IF SQLCODE <> 0 THEN
    RAISE OTHERS;
    END IF;
    EXCEPTION
    WHEN exception1 THEN -- Indica el caso de que se alcance la excepción asignada por el usuario.
    DBMS_OUTPUT.PUT _LINE('1ra. excepción de usuario capturara');
    WHEN exception2 THEN -- Indica el caso de que se alcance la excepción de sistema.
    DBMS_OUTPUT.PUT _LINE('2da. excepción de usuario (Indeterminada) capturada');
    WHEN OTHERS THEN
    SET (dcode = SYSPROC.SQLERRM (ecode));
    DBMS_OUTPUT.PUT _LINE(dcode);
    END prueba;



    Could anyone helpme please?
Working...