Subject Re: [firebird-support] Update query and trigger
Author Bogdan Mihalache
if(new.field_b>0) and new.field_a = old.field_a then
     dosomething;
else
     dosomethingelse;



-------- Original message --------
From: "Dr. Fabrizio Villanova" <fvillanova@...>
Date:
To: firebird-support@yahoogroups.com
Subject: [firebird-support] Update query and trigger


 

hi all,
 
for example:

mytable
(
....
field_A varchar(x),
field_B integer default 0,
....
)

query:
update mytable set field_a=XXX where yyyyy;

mytrigger: before update
if(new.field_b>0) then
     dosomething;
else
     dosomethingelse;

the trigger must operate only when i update field_b not when i'm updating field_A.

Calling the first query new.field_b is always '0' and 'dosomethingelse' is executed; checking for "field_b is not null" is useless, it's '0'.
There is a way to recognize that the query is not altering field_b?

thank you.
Fabrizio