|Subject||Re: [firebird-support] Match two fields in same table using a trigger|
> Dne 11.3.2011 8:51, thedevguy napsal(a):What's wrong with ALWAYS setting field2 = field1? If they're different, you
>> 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.
want them to be the same. Which means that if they're the same, you can copy
its value anyway.
Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!
>> I tried something like the following but it doesn't work.
>> if (new.field1<> old.field2) then
>> new.field2 = new.field1;
>> Any help would be greatly appreciated.
> This kind of triggers works fine for me. I am pretty sure your
> particular implementation has some bugs, e.g. one of the fields contains
> a NULL value and the usual "comparison of anything to null is almost
> always false" GOTCHA kicks in.
> Visit http://www.firebirdsql.org and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
> Also search the knowledgebases at http://www.ibphoenix.com
> Yahoo! Groups Links