Subject | Computing column in BEFORE INSERT trigger |
---|---|
Author | Alec Swan |
Post date | 2010-12-21T18:30:28Z |
Hello,
I am trying to denormalize two tables by copying SOURCE_ID column from one
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?
Thanks
[Non-text portions of this message have been removed]
I am trying to denormalize two tables by copying SOURCE_ID column from one
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?
Thanks
[Non-text portions of this message have been removed]