• Welcome, Guest. Please login.
 
October 21, 2019, 02:24:25 am

News:

Welcome to the SQLitening support forums!


WHEN in a trigger

Started by Fim, November 30, 2017, 06:45:46 am

Previous topic - Next topic

Fim

This works well:
CREATE TRIGGER ARB_TRIGG_01 INSERT ON ARB FOR EACH ROW BEGIN UPDATE VOR SET FK_KOSTN_ARB_SUM = FK_KOSTN_ARB_SUM + NEW.FK_KOSTN WHERE ORDERNR = NEW.ORDERNR; END

But not this:
CREATE TRIGGER ARB_TRIGG_01 INSERT ON ARB FOR EACH ROW WHEN OPKOD = 'LEGO' BEGIN UPDATE VOR SET FK_KOSTN_ARB_SUM = FK_KOSTN_ARB_SUM + NEW.FK_KOSTN WHERE ORDERNR = NEW.ORDERNR; END
I do not understand what it's wrong.
Pls help
/Fim W.
Fim W

Bern Ertl

... FOR EACH ROW WHEN NEW.OPKOD = ...

When you reference columns for the row that is activating the trigger, you must include NEW. or OLD. as appropriate.

Fim

Thank you, I should have been able to figure it out myself.

/Fim W.
Fim W