I have the following trigger:
(for those of you familar with Thread178-1346593, I ended up modifing the originating program so there's a single record for each courtroom entry and the trigger fires for each courtroom).
My subsequent issue has now turned into this. If the officer is checking in during morning hours, I only want to update records with the trigger above that meet the criteria WHERE HERTIM < 1200 and inversely, if it's in the afternoon, I want to update records WHERE HERTIM >= 1200
Is there a way I can determine in the trigger if it's AM or PM, maybe assign that to a variable to determine what the final WHERE clause should be?
Thanks!
Leslie
Leslie
Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual
Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins
Code:
CREATE TRIGGER CMLIB.CHKIN_INSERT_UPDATE_CHKINHEARINGS
AFTER INSERT ON CMLIB.CMPCHKINS
REFERENCING NEW N
FOR EACH ROW
MODE DB2ROW
BEGIN
IF n.STATUS = 'C' THEN
UPDATE CMLIB.CMPCKINHEARINGS SET CHKINTIME = n.CHKINTIME WHERE OFFNUM = n.OFFNUM AND MAGENC = n.MAGENC AND CRTROM = (n.Courtrooms);
ElseIF n.STATUS = 'M' THEN
UPDATE CMLIB.CMPCKINHEARINGS SET MSGDATE = n.MSGDATE, MSGTIME = n.MSGTIME, MSGSOURCE = n.MSGSOURCE, MESSAGE = n.MESSAGE WHERE OFFNUM = n.OFFNUM AND MAGENC = n.MAGENC;
END IF;
END;
(for those of you familar with Thread178-1346593, I ended up modifing the originating program so there's a single record for each courtroom entry and the trigger fires for each courtroom).
My subsequent issue has now turned into this. If the officer is checking in during morning hours, I only want to update records with the trigger above that meet the criteria WHERE HERTIM < 1200 and inversely, if it's in the afternoon, I want to update records WHERE HERTIM >= 1200
Is there a way I can determine in the trigger if it's AM or PM, maybe assign that to a variable to determine what the final WHERE clause should be?
Thanks!
Leslie
Leslie
Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual
Essential reading for database developers:
The Fundamentals of Relational Database Design
Understanding SQL Joins