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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trigger 1

Status
Not open for further replies.

anniez

IS-IT--Management
Apr 13, 2001
43
US
I don't know why I'm having so much trouble with this!

When fieldA gets changed to "0"
I want fieldB and fieldC to get changed to "000"


if :new.fielda="0"
then
update table.fieldA="000"
fieldB="000"
end if;
 
For the love of pete!
Here's the problem: you can't change a :NEW value in an AFTER update trigger! This has to be a BEFORE update trigger.

I just tried this and it works; Anniez, I think we can now put you out of your misery:

CREATE OR REPLACE TRIGGER anniez_trigger
BEFORE UPDATE OF STATUS
ON anniez
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
IF :NEW.status='0'
THEN
:NEW.department:='000';
:NEW.building:='000';
END IF;
END;
 
You just made me very, very happy.

Thanks
Annie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top