Re: triggering in 7.31
Posted in 2008
ECS wrote:
>> "scottishpoet" <dryburghj@yahoo.com> wrote in message
>> news:f76d5ddb-9a86-4da9-be8a->0c43d2ab3e7e@2g2000hsn.googlegroups.com...
>> On Sep 24, 7:36 am, "ECS" <z...@mailinator.com> wrote:
>>> An update trigger was created on a few fields of a table.
>>> The trigger is activated even if another field is updated.
>>> Is this a bug in 7.31.FC6?
>>>
>>> Thanks
>>
>> I believe a trigger is created on a table, not on a field(column) of
>> a table.
>>
>> If you have an update trigger on the table the trigger will be
>> activated every time the table is updated.
>> It should only take the action documented in the trigger if the fields
>> affect change appropriately.
>
>
> So, any change on one of the 10 columns of table "oldb17b".table1 will
> activated this trigger. Correct??
> I thought that it would only be activated by changes on colm1, 2 of 3,
> not on changes on colm4 - 10.
>
>
> create trigger "oldb17b".upd_table1
> update of
> colm1,
> colm2,
> colm3
> on "oldb17b".table1
> referencing new as changedrow
> for each row
> ( insert into "oldb17b".trg_table1
> ( messagestatus,
> triggersequence,
> colm1,
> colm2,
> colm3
> )
> values
> ( 'U',
> NULL,
> changedrow.colm1,
> changedrow.colm2,
> changedrow.colm3
> )
> );
>
>
>
The UPDATE and SELECT (you don't have these on 7.31) will only fire if the
query includes any of the specified columns.
INSERT and DELETE triggers do not specify columns.
You can have more than one SELECT/UPDATE triggers on 7.31 if they use disjunct
sets of columns.
In v11.10+ you can have more than one trigger even if they use the same columns.
Make sure that the trigger you're considering is the only trigger in the table
(dbschema -d database -t table). If it is and it's being fired without any
reference to one of the columns in the trigger definition something is wrong.
Regards.
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...