Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating Oracle Update Trigger

Status
Not open for further replies.

davidrm

Programmer
Jun 5, 2002
3
US
Hello All,
I am completely new to triggers and could use some assistance. I've created a table called Audit_Carrier. I'd like for this table to have a row inserted whenever there is a change of carrier_id on the OCN table. The row should consist of ocn_id, customer_id, and old carrier id. I've tried this several times with no positive outcome. Any help on this would be greatly appreciated.

CREATE TABLE AUDIT_CARRIER (OCN_ID CHAR(20), CUSTOMER_ID CHAR(20), OLD_CARRIER_ID CHAR(10) );

CREATE OR REPLACE TRIGGER CHECK_CARRIER
BEFORE UPDATE ON OCN
FOR EACH ROW
WHEN (NEW.CARRIER_ID <> OLD.CARRIER_ID)
BEGIN
INSERT INTO AUDIT_CARRIER (OCN_ID, CUSTOMER_ID, OLD_CARRIER_ID)
VALUES :)OLD.ID, :OLD.CUSTOMER_ID, :OLD.CARRIER_ID);
END;

 
What was your &quot;negative&quot; outcome?

Regards, Dima
 
It didn't capture any events, even though there were situations where the carrier id had changed.
 
I see 2 possible reasons:

1. initial (old) value for CARRIER_ID was NULL, thus the condition NEW.CARRIER_ID <> OLD.CARRIER_ID was NOT evaluated as TRUE
2. the trigger was DISABLEd

Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top