Reputation: 41
I am in the need of a trigger which will fire on any insert or updates on the specific table and while inserting or updating will substitute a credit card number column of the new row to something bogus such as "1111 1111 1111 1111"
Here is what I cooked up but it doesn't seem to work.
CREATE or REPLACE TRIGGER trigger_name AFTER INSERT ON table1
FOR EACH ROW
BEGIN
update table1 set cc_number_field = '11';
END;
I am on Oracle 10 if that matters.
Upvotes: 4
Views: 15291
Reputation: 3872
Not tested:
CREATE OR REPLACE TRIGGER t BEFORE INSERT on ON table1 FOR EACH ROW begin :new.cc_number_field = '11'; END;
Upvotes: 0
Reputation: 311018
It's much easier to manipulate the incoming :NEW
line with a "before" trigger:
CREATE OR REPLACE TRIGGER table1_cc_trigger
BEFORE INSERT OR UPDATE ON table1
FOR EACH ROW
BEGIN
:NEW.cc_number_field := '1111 1111 1111 1111';
END;
/
Upvotes: 10