Subject Re: [firebird-support] update a field in after insert update
Author Helen Borrie
At 12:21 AM 15/03/2009, you wrote:
>hi ,
>i have to update a field of a table when a new record of the same table
>is inserted .

It looks as though some of the people posting answers didn't notice that you said " record of the same table...".

>i am tryng to use an after insert trigger , i tryed
> update test_table s
> set s.kyriga = 'test' ;
>and of course it affected all the rows , bu i want update only
>the inserted row

If your trigger is for the *same* table, you shouldn't even try to "update" the current inserting row this way.

Instead, write a BEFORE INSERT trigger to assign the value directly to that column as part of the actual insert:

create trigger bi_test_table for test_table
active before insert
position 2 as
new.kiriga = 'test';

Note, I suggested position 2 here in case you have another Before Insert trigger that you wish to be executed first. However, if you *want* to have only one Before Insert trigger, it will work fine to modify that trigger to include this statement after other operations the trigger would execute.