Re: insert trigger problem
Posted in 1997
S'ren 'rendahl Mikkelsen wrote:
>
> Can an insert trigger update the row data that starts the trigger.
>
> E.g.
> If I have table tab_1 and procedure prod_2 as illustrated below.
>
> CREATE TABLE tab_1
> (
> col1 INTEGER,
> col2 INTEGER);>
> CREATE PROCEDURE prod_1(column_1 INTEGER)
> RETURNING INTEGER;> RETURN column_1;
> END PROCEDURE;
>
> The statement "insert into tab_1 (col1) values (34);" will insert 34
> into col1.
> Is it possible to create an insert trigger on tab_1 that calls prod_1
> and place the result of prod_2 in col2 ?
>
> Below trigger does not do the job.
>
> CREATE TRIGGER trig_1> INSERT ON tab_1
> REFERENCING NEW AS post
> FOR EACH ROW(EXECUTE PROCEDURE prod_1(post.col1) INTO post.col2);
I think it is:
FOR EACH ROW (UPDATE post set col2 = prod_1(col1))
But then again the trigger implementation might be so silly as
to update the whole table, so be careful !!!!!!!!!