Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger problem, OS390/DB2 v7

Status
Not open for further replies.

ulfnsc

Programmer
May 7, 2003
2
SE
Trigger problem, OS-390/DB2 v7
Hej
Trigger problem.
OS-390/DB2 v7

(GiltigFom and GiltigTom IS NULL)
When the trigger below is executed it is only the first CASE that is SET.
-----------
Code:
DROP TRIGGER TR_INSTAANST

CREATE TRIGGER tr_insTAAnst NO CASCADE BEFORE INSERT ON TAAnst 
REFERENCING NEW as NEW_VAR
FOR EACH ROW MODE DB2SQL
WHEN (NEW_VAR.A06_GiltigFom IS NULL OR NEW_VAR.A06_GiltigTom IS NULL)
BEGIN ATOMIC
SET NEW_VAR.A06_GiltigFom =
CASE
WHEN NEW_VAR.A06_GiltigFom IS NULL THEN CURRENT DATE
END,
NEW_VAR.A06_GiltigTom =
CASE
WHEN NEW_VAR.A06_GiltigTom IS NULL THEN '2999-12-31'
END; 
END
--------------

Any help would be appreciated.
/uffe

 
You could try writting 2 triggers as in -

CREATE TRIGGER tr_insTAAnst1 NO CASCADE BEFORE INSERT ON TAAnst
REFERENCING NEW as NEW_VAR
FOR EACH ROW MODE DB2SQL
WHEN (NEW_VAR.A06_GiltigFom IS NULL)
BEGIN ATOMIC
SET NEW_VAR.A06_GiltigFom = CURRENT DATE;
END

CREATE TRIGGER tr_insTAAnst2 NO CASCADE BEFORE INSERT ON TAAnst
REFERENCING NEW as NEW_VAR
FOR EACH ROW MODE DB2SQL
WHEN (NEW_VAR.A06_GiltigTom IS NULL)
BEGIN ATOMIC
SET NEW_VAR.A06_GiltigTom = '2999-12-31';
END

I have found DB2 is happy enough to have a bunch of triggers on any given table without too much performance hit.

Cheers,
Steve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top