locked
oracle simple trigger RRS feed

  • Question

  • User2090756951 posted
    CREATE OR REPLACE TRIGGER TRG_ADD_STAFF
    BEFORE INSERT ON STAFF
    FOR EACH ROW
    DECLARE
    EXITCOUNT NUMBER:=0;
    BEGIN 
    SELECT COUNT(StaffIC) INTO EXITCOUNT FROM STAFF WHERE StaffIC= :NEW.StaffIC;	
    IF EXITCOUNT >= 1 THEN
    RAISE_APPLICATION_ERROR(-20005, 'DUPLICATE CUSTOMER IC !!! ');
    END IF;
    END;
    /
    ------------------------------------------------------------------------------
    
    INSERT INTO STAFF VALUES('Stt00001', '123','Lee Keat Siang', 920409025097, 'Male', 'Admin',9999,'a_max09041992@hotmail.com', '0175228334');
    
    ---------------------------------------------------------------------------
    ERROR at line 1:
    ORA-20005: DUPLICATE CUSTOMER IC !!!
    ORA-06512: at "MICHAEL.TRG_ADD_STAFF", line 6
    ORA-04088: error during execution of trigger 'MICHAEL.TRG_ADD_STAFF'

    why the error ORA-06512 and 04088 will occur? how to slove?

    Monday, July 22, 2013 4:25 AM

Answers