Re: trigger on insert: updating one value of the same table
Posted in 2009
I have IDS 9.40 ( we will upgrade soon to 11.50).
However, here it is what documentation on ibm site says for v.10:
If the trigger has an INSERT event, the trigger action can be an
UPDATE statement that references a column in the triggering table, but
this column cannot be a column for which a value was supplied by the
trigger event.
If the trigger has an INSERT event, and the trigger action updates the
triggering table, the columns in both statements must be mutually
exclusive. For example, assume that the triggering statement inserts
values for columns cola and colb of table tab1:
INSERT INTO tab1 (cola, colb) VALUES (1,10)Now consider the following
trigger actions. The first UPDATE is valid, but the second one is not,because it updates column colb even though the trigger event already
supplied a value for column colb:
UPDATE tab1 SET colc=100; --OK
UPDATE tab1 SET colb=100; --INVALID
If this is true for v.9.40 which I think it is, then Art's suggestion
will be probably the best way to go.
On Thu, Dec 10, 2009 at 3:38 PM, Gentian Hila <genti.tech@gmail.com> wrote:
> I have a program that is closed to us. It inserts a new row, every
> column of the table.
>
> I want one to update the value of one column on the inserted row.
>
> I tried a INSERT on trigger but since the column is included on the
> insert it gives me the error:
>
> "table or column matches object referenced in triggering statement".
>
> Is there a way that I can achieve this through a trigger?
>
> That would be extremely helpful.
>
> Thank you,
>