Re: trigger on insert: updating one value of the same table
Posted in 2009
On 11 дек, 18:57, Gentian Hila <genti.t...@gmail.com> wrote:
> I did a test on this as the whole SQL is a long thing and has other
> parts in there that would simply make it more confusing.
>
> 1) Create a test table
>
> create table test1
> (cust_num CHAR(10),
> desc CHAR(30),
> val INTEGER)>
> 2) Created a procedure that returns an integer
>
> create procedure p_test1()
> RETURNING INTEGER> return 100;
> END PROCEDURE
>
> 3) Tried to create a trigger just like you suggest:
>
> CREATE TRIGGER t_test1> INSERT ON test1
> referencing new as new
> for each row
> (execute procedure p_test1() INTO new.val);
>
> but it gives me an error:
>
> Incorrect use of old or new values correlation name inside trigger. So
> I guess this can be done on update but not on insert
>
You should not use correlation names in this case.
Works for me in insert trigger.
CREATE TRIGGER t_test1INSERT ON test1
referencing new as new
for each row
(execute procedure p_test1() INTO val);