Subject | Re: [firebird-support] update a field in after insert update |
---|---|
Author | Helen Borrie |
Post date | 2009-03-15T21:19:01Z |
At 12:21 AM 15/03/2009, you wrote:
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
begin
new.kiriga = 'test';
end
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.
./heLen
>hi ,It looks as though some of the people posting answers didn't notice that you said "...new record of the same table...".
>i have to update a field of a table when a new record of the same table
>is inserted .
>i am tryng to use an after insert trigger , i tryedIf your trigger is for the *same* table, you shouldn't even try to "update" the current inserting row this way.
>
>..
> update test_table s
> set s.kyriga = 'test' ;
>..
>
>and of course it affected all the rows , bu i want update only
>the inserted row
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
begin
new.kiriga = 'test';
end
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.
./heLen