Subject | Re: [firebird-support] Computing column in BEFORE INSERT trigger |
---|---|
Author | Thomas Steinmaurer |
Post date | 2010-12-21T19:03:59Z |
Hello,
previous versions it should be:
CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
BEFORE INSERT OR UPDATE
AS BEGIN
select source_id from copy where id = :NEW.COPY_ID into :NEW.source_id;
END;
This all without knowing your exact error message. ;-)
--
With regards,
Thomas Steinmaurer
Upscene Productions
http://www.upscene.com
http://blog.upscene.com/thomas/
Download LogManager Series, FB TraceManager today!
Continuous Database Monitoring Solutions supporting
Firebird, InterBase, Advantage Database, MS SQL Server
and NexusDB!
> I am trying to denormalize two tables by copying SOURCE_ID column from oneWhile your provided syntax is newly supported in Firebird 2.5, in
> table to another. I am creating a trigger which executes before an insert
> and calculates the value of one of the columns for the inserted row. Why do
> I get a syntax error when running the following?
>
> CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
> BEFORE INSERT OR UPDATE
> AS BEGIN
> NEW.source_id = (select source_id from copy where id = NEW.COPY_ID);
> END;
>
> I know I could use computed columns, but I need that column to be indexed.
> Are there any other ways to do this?
previous versions it should be:
CREATE TRIGGER Source_Id_Upd FOR PHYSICAL_COPY
BEFORE INSERT OR UPDATE
AS BEGIN
select source_id from copy where id = :NEW.COPY_ID into :NEW.source_id;
END;
This all without knowing your exact error message. ;-)
--
With regards,
Thomas Steinmaurer
Upscene Productions
http://www.upscene.com
http://blog.upscene.com/thomas/
Download LogManager Series, FB TraceManager today!
Continuous Database Monitoring Solutions supporting
Firebird, InterBase, Advantage Database, MS SQL Server
and NexusDB!