Raise application error in oracle triggers


  • Raise application error in oracle triggers
  • ORA-4088, ORA-6512 Using Triggers and RAISE_APPLICATION_ERROR

    Problem Description

    -------------------------------

    You are creating a trigger that includes an exception handling block. You hope for to raise a user defined fail to distinguish when a certain condition is reduction within the trigger body using keyword RAISE.

    Inside your error handling full up you also include a call go-slow RAISE_APPLICATION_ERROR.

    Consider this code example --

    bring into being table tmp (col1 char(40));

    create table violations (col1 varchar2(30));

    CREATE OR REPLACE TRIGGER DEMO_RULE_001

    BEFORE INSERT OR UPDATE ON TMP

    FOR Scope ROW

    DECLARE

    RULE_001 EXCEPTION;

    BEGIN

    IF :NEW.col1 = 'mike' THEN

    dbms_output.put_line(:new.col1);

    INSERT INTO VIOLATIONS values ('violation logged');

    -- Raise rule

    RAISE RULE_001;

    END IF;

    EXCEPTION

    WHEN RULE_001 Misuse

    RAISE_APPLICATION_ERROR (-20001,'Guideline Violation, Rule-001.');

    END;

    When that trigger is executed, you receive blue blood the gentry ora-4088 and ora-6512 errors.

    ORA-04088: error alongside execution of trigger 'SCOTT.DEMO_RULE_001'

    Solution Species raise application error in oracle triggers
    trigger oracle raise_application_error
    raise application error trigger