Good day everyone!
I am new to the world of Oracle and my boss as asked me to create a trigger. The purpose of the triger is to insert default values in the field when the row is been inserted.
If someone change the value of the PD_OBJ_TYPE to a 1 than I want to have the values of the other fields change also.
If someone change the value of PD_OBJ_TYPE to 0 again, I want the values change back as if they where first inserted.
Here is my trigger. Can anyone tell me why it does not work and what I should to make it work?
Thanks!
CREATE OR REPLACE TRIGGER "TRG_RO_TEST"
BEFORE INSERT OR UPDATE OF "APPLICATION", "CLASSIFIED", "CREATION_DATE", "LAST_ACCESS_TIME",
"LAST_EDIT_DATE", "OBJ_DATE", "PD_OBJ_TYPE", "READONLY_DATE", "RIMSOFFICIAL", "STATUS"
ON "PROFILE"
FOR EACH ROW
BEGIN
IF INSERTING THEN
:NEW.READONLY_DATE := ld.CREATION_DATE;
:NEW.STATUS := 19;
:NEW.PD_OBJ_TYPE := 0;
:NEW.OBJ_DATE := SYSDATE;
:NEW.RIMSOFFICIAL := 1;
:NEW.CLASSIFIED := 1;
ELSE
BEGIN
IF :NEW.PT_OBJ_TYPE = 1
THEN
:NEW.STATUS := 0;
:NEW.RIMSOFFICIAL := 0;
:NEW.CLASSIFIED := 0;
ELSE
:NEW.READONLY_DATE := ld.CREATION_DATE;
:NEW.STATUS := 19;
:NEW.PD_OBJ_TYPE := 0;
:NEW.OBJ_DATE := SYSDATE;
:NEW.RIMSOFFICIAL := 1;
:NEW.CLASSIFIED := 1;
END IF;
END IF;
END;
END;
I am new to the world of Oracle and my boss as asked me to create a trigger. The purpose of the triger is to insert default values in the field when the row is been inserted.
If someone change the value of the PD_OBJ_TYPE to a 1 than I want to have the values of the other fields change also.
If someone change the value of PD_OBJ_TYPE to 0 again, I want the values change back as if they where first inserted.
Here is my trigger. Can anyone tell me why it does not work and what I should to make it work?
Thanks!
CREATE OR REPLACE TRIGGER "TRG_RO_TEST"
BEFORE INSERT OR UPDATE OF "APPLICATION", "CLASSIFIED", "CREATION_DATE", "LAST_ACCESS_TIME",
"LAST_EDIT_DATE", "OBJ_DATE", "PD_OBJ_TYPE", "READONLY_DATE", "RIMSOFFICIAL", "STATUS"
ON "PROFILE"
FOR EACH ROW
BEGIN
IF INSERTING THEN
:NEW.READONLY_DATE := ld.CREATION_DATE;
:NEW.STATUS := 19;
:NEW.PD_OBJ_TYPE := 0;
:NEW.OBJ_DATE := SYSDATE;
:NEW.RIMSOFFICIAL := 1;
:NEW.CLASSIFIED := 1;
ELSE
BEGIN
IF :NEW.PT_OBJ_TYPE = 1
THEN
:NEW.STATUS := 0;
:NEW.RIMSOFFICIAL := 0;
:NEW.CLASSIFIED := 0;
ELSE
:NEW.READONLY_DATE := ld.CREATION_DATE;
:NEW.STATUS := 19;
:NEW.PD_OBJ_TYPE := 0;
:NEW.OBJ_DATE := SYSDATE;
:NEW.RIMSOFFICIAL := 1;
:NEW.CLASSIFIED := 1;
END IF;
END IF;
END;
END;