Subject | RE: [firebird-support] RC8 computed fields in trigger problem |
---|---|
Author | Thomas Steinmaurer |
Post date | 2004-01-08T14:11:55Z |
> At January 8, 2004, 07:11, Helmut Steinberger wrote:RECREATE TABLE COMP_LOG
>
> > Has there something been changed in FB1.5 RC8 regarding the use of
> > computed fields in triggers?
>
> > I have a table with a computed field, which depents on other fields of
> > this table. The fields, used to compute the computed field are set in
> > the before insert trigger of the table. In the after insert trigger,
> > the computed field is used, but it is null, allthough the fields where
> > it is computed from are correctly set to a value not null in the
> > before insert trigger.
> > With FB1.5 RC 7 it worked as expected.
>
> > Please tell me what has been changed in RC 8 regarding this. In the
> > release notes I could not find anything about it.
>
> I've posted your message on the Firebird-Devel group. And, if you can
> create a reproducible test case and send it, it would be greatly
> appreciated also.
(
ID BIGINT NOT NULL,
VC3 VARCHAR( 60),
CONSTRAINT PK_COMP_LOG PRIMARY KEY (ID)
);
COMMIT WORK;
RECREATE TABLE COMP
(
ID BIGINT NOT NULL,
VC1 VARCHAR( 20),
VC2 VARCHAR( 40),
VC3 VARCHAR( 60) COMPUTED BY ( VC1 || ' ' || VC2 ),
CONSTRAINT PK_COMP PRIMARY KEY (ID)
);
COMMIT WORK;
SET TERM ^^ ;
CREATE TRIGGER TRI_COMP_BI FOR COMP ACTIVE BEFORE INSERT POSITION 0 AS
begin
NEW.VC1 = 'VC1_Value';
NEW.VC2 = 'VC2_Value';
end
^^
SET TERM ; ^^
COMMIT WORK;
SET TERM ^^ ;
CREATE TRIGGER TRI_COMP_AI FOR COMP ACTIVE AFTER INSERT POSITION 0 AS
begin
insert into comp_log values (new.id, new.vc3);
end
^^
SET TERM ; ^^
COMMIT WORK;
insert into comp (id) values (1);
COMMIT WORK;
select * from comp_log;
ID VC3
---------------------------------------------------------------------
1
Just a gotcha of the export, but VC3 holds the NULL state.
Firebird 1.5 RC8 SuperServer on Windows 2000 Prof. SP3
HTH,
Thomas