Hello,
I'm having trouble solving the following problem with DB2 UDB 8.2.
I need to create a trigger that performs certain extra constraint
validations (temporal uniqueness). One of the tables has no primary
key.
I'm having trouble expressing an update trigger that checks for
existing rows, contemporary to the updated one, but exclusing the
updated one.
In effect the trigger always signals my message on updates, since the
updated row conflicts with itself.
CREATE TRIGGER un_ch_name_upda te
BEFORE UPDATE ON cmd$child
REFERENCING NEW AS N
FOR EACH ROW
WHEN (N.name in (select name
from cmd$child
where parent_sid = N.parent_sid
and (vts <= N.vte or n.vte is null)
and (vte n.vts or vte is null)))
SIGNAL SQLSTATE '75000' SET MESSAGE_TEXT='T he NAME is already present
in the time interval under the same PARENT_SID';
In oracle I could probably just have added "and rownum <n.rownum".
Any ideas?
TIA,
-dennis
I'm having trouble solving the following problem with DB2 UDB 8.2.
I need to create a trigger that performs certain extra constraint
validations (temporal uniqueness). One of the tables has no primary
key.
I'm having trouble expressing an update trigger that checks for
existing rows, contemporary to the updated one, but exclusing the
updated one.
In effect the trigger always signals my message on updates, since the
updated row conflicts with itself.
CREATE TRIGGER un_ch_name_upda te
BEFORE UPDATE ON cmd$child
REFERENCING NEW AS N
FOR EACH ROW
WHEN (N.name in (select name
from cmd$child
where parent_sid = N.parent_sid
and (vts <= N.vte or n.vte is null)
and (vte n.vts or vte is null)))
SIGNAL SQLSTATE '75000' SET MESSAGE_TEXT='T he NAME is already present
in the time interval under the same PARENT_SID';
In oracle I could probably just have added "and rownum <n.rownum".
Any ideas?
TIA,
-dennis
Comment