Subject | Problem with my Trigger |
---|---|
Author | Matze |
Post date | 2006-12-12T19:46:02Z |
Hi Firebird Group
I've created the follwoing Trigger:
CREATE TRIGGER USER_BU0 FOR "USER" ACTIVE BEFORE UPDATE POSITION 0 AS
begin
if ((new.rbcard is not NULL)
or (new.anrede is not NULL)
or (new.v_name is not NULL)
or (new.n_name is not NULL)
or (new.telefon is not NULL)
or (new.handy is not NULL)
or (new.email is not NULL)
or (new.comment is not NULL)
or (new.bonus is not NULL)) then
new.last_changed = current_timestamp;
end
What I want is:
The fiield last_changed has to be set to the timnestamp of the last editing
of the dataset, but only if important fields are manipulated. The table
"USER" also hat the field last_seen. If thios filed is set in a Query the
Trigger has to to nothing.
E.g.
The Query UPDATE "USER" SET telefon = '123456789789' shold activate the
trigger but
UPDATE "USER" SET last_seen = current_timestamp should do nothing.
But my trigger always updates the last_changed field.
What am I doing wrong ?
Thanks a lot !
Matthias Feist
I've created the follwoing Trigger:
CREATE TRIGGER USER_BU0 FOR "USER" ACTIVE BEFORE UPDATE POSITION 0 AS
begin
if ((new.rbcard is not NULL)
or (new.anrede is not NULL)
or (new.v_name is not NULL)
or (new.n_name is not NULL)
or (new.telefon is not NULL)
or (new.handy is not NULL)
or (new.email is not NULL)
or (new.comment is not NULL)
or (new.bonus is not NULL)) then
new.last_changed = current_timestamp;
end
What I want is:
The fiield last_changed has to be set to the timnestamp of the last editing
of the dataset, but only if important fields are manipulated. The table
"USER" also hat the field last_seen. If thios filed is set in a Query the
Trigger has to to nothing.
E.g.
The Query UPDATE "USER" SET telefon = '123456789789' shold activate the
trigger but
UPDATE "USER" SET last_seen = current_timestamp should do nothing.
But my trigger always updates the last_changed field.
What am I doing wrong ?
Thanks a lot !
Matthias Feist