Unanswered: having trouble with "before insert" trigger
I have created a before update trigger that I would like to use to prevent null values in a column that has unique values. In case this value is not submitted at the insertion I would like the trigger to write in that column the ID value which is the primary key of the table. Both columns are of the same type - bigint
CREATE TRIGGER TRIGG_1 BEFORE INSERT ON MY_TABLE
REFERENCING NEW AS new_row FOR EACH ROW MODE DB2SQL
WHEN ( new_row.UNIQUE_FIELD IS NULL )
SET new_row.UNIQUE_FIELD = new_row.P_ID;
It doesnt work and I have no idea why. I tried to put a "SIGNAL" statement into the "WHEN" section to see if it isnt being skipped and I actually got the signal message after running the insert query when the UNIQUE_VALUE was null...
It is a DB2 Express-c database
DB2version: "DB2 v126.96.36.199", "s091114", "IP23028", and Fix Pack "1".