<DB2 z/OS V7> Determining updated columns in a trigger

Wayne Driscoll

<DB2 z/OS V7> Determining updated columns in a trigger
I am trying to implement a trigger that will cause a column to be set UNLESS
that column is being updated in the triggering statement.

Is this possible, or am I out of luck? I tried using old and new
transitional variables and checking for the values being the same, but that
wouldn't help in the situation where I am including the column in the update
statmement just to avoid the update.

Example:

Table (
Col1 integer,
Col2 integer,
Col3 integer,
Col4 char(8)
)

I want to set col4 = user, unless col4 is in the update statement. Ie. if
statement:
Update table set col1=3000 where col3=1;

I want col4=user, but for statement
Update table set col1=3000,col4='TEST' where col3=1;
I don't want col4 set to the user.
Thanks in advance,
Wayne Driscoll
Product Developer
Western Metal Supply
NOTE: All opinions are strictly my own.


---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm

Walter Jani&#223;en

Re: <DB2 z/OS V7> Determining updated columns in a trigger
(in response to Wayne Driscoll)
Wayne

I think one option would be, to restrict the trigger on all but one column.
And the only column excluded would be col4.

CREATE TRIGGER AFTER UPDATE of col1, col2, col3, col5 and so on

---------------------------------------------------------------------------------
Welcome to the IDUG DB2-L list. To unsubscribe, go to the archives and home page at http://www.idugdb2-l.org/archives/db2-l.html. From that page select "Join or Leave the list". The IDUG DB2-L FAQ is at http://www.idugdb2-l.org. The IDUG List Admins can be reached at [login to unmask email] Find out the latest on IDUG conferences at http://conferences.idug.org/index.cfm