Subject | RE: [firebird-support] Match two fields in same table using a trigger |
---|---|
Author | Paul Lopez |
Post date | 2011-03-11T07:53:34Z |
Hi,
Make sure that your trigger is before insert, not after insert.
After insert happens after the data is already written.
Paul.
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of thedevguy
Sent: Friday, 11 March 2011 3:52 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Match two fields in same table using a trigger
Is there a way to sync two columns in the same table using a trigger. For example I have field1 and field2. On an insert or an update I would like field2 = field1 if they are different.
I tried something like the following but it doesn't work.
TRIGGER:
if (new.field1 <> old.field2) then
new.field2 = new.field1;
Any help would be greatly appreciated.
[Non-text portions of this message have been removed]
Make sure that your trigger is before insert, not after insert.
After insert happens after the data is already written.
Paul.
From: firebird-support@yahoogroups.com [mailto:firebird-support@yahoogroups.com] On Behalf Of thedevguy
Sent: Friday, 11 March 2011 3:52 PM
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Match two fields in same table using a trigger
Is there a way to sync two columns in the same table using a trigger. For example I have field1 and field2. On an insert or an update I would like field2 = field1 if they are different.
I tried something like the following but it doesn't work.
TRIGGER:
if (new.field1 <> old.field2) then
new.field2 = new.field1;
Any help would be greatly appreciated.
[Non-text portions of this message have been removed]