Subject Re: error attempted update of read-only column creating a trigger
Author Didier Gasser-Morlay
--- In firebird-support@yahoogroups.com, Dmitry Yemanov <dimitr@...>
wrote:
Dmitry,

You're right there was an assignment to a NEW.* column in another
after trigger.

What is the best course of action to update a column in the NEW record
from an after trigger, /without/ re-firing the triggers ? Is it
possible ?

Didier



> Didier Gasser-Morlay wrote:
> >
> > I am puzzled by the following error message. I am porting a database
> > from 1.5 to 2.0.1 and when creating the following trigger:
> >
> > SET TERM ^ ;
> > CREATE TRIGGER EMPLOYEE_BI0 FOR EMPLOYEE ACTIVE
> > BEFORE INSERT POSITION 0
> > AS
> > begin
> > if (new.username is not null) then
> > if (exists (select * from vlogin where vlogin.username =
> > new.username)) then
> > exception USERNAME_EXISTS;
> > end^
> > SET TERM ; ^
> >
> > Engine Code : 335544359
> > Engine Message :
> > attempted update of read-only column
>
> This means that you're attempting to assign to an improper trigger
> context (OLD in any trigger or NEW in after-trigger).
>
> > Note: vlogin is a view on two tables:
> > employees and contacts
>
> I'd check their triggers as well, as the error could be caused by the
> referenced objects.
>
>
> Dmitry
>