MySQL Forums
Forum List  »  Triggers

Problem with Trigger
Posted by: Reinhard Windpassinger
Date: September 10, 2012 11:56PM

Hello,

i have a little problem with my trigger.
i created a trigger:

BEGIN

IF((SELECT `Wert` FROM parameter_history WHERE `BusNr` = NEW.BusNr AND `MesswertNr` = NEW.MesswertNr ORDER BY `Timestamp` DESC LIMIT 1) != NEW.Value)
THEN
INSERT INTO parameter_history (`BusNr`, `MesswertNr`, `Value`) VALUES (NEW.BusNr, NEW.MesswertNr, NEW.Value);
END IF;

END

The event of the trigger is after an update.
if there is already a "New.Value" it works really good.
but if there is no "New.Value" in my database it doesn`t work and i don`t know why.
The problem is, that i can`t get a value back from "NEW.Value" when there is actually no entry in my table.

Can anybody help me?

kind regards

Options: ReplyQuote


Subject
Views
Written By
Posted
Problem with Trigger
2733
September 10, 2012 11:56PM
1297
September 11, 2012 09:33AM
1289
September 12, 2012 02:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.