Help on a Trigger

Last Post 06 Dec 2007 11:14 AM by phsatech. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
phsatech
New Member
New Member

--
04 Dec 2007 01:04 PM
I'm pretty new to triggers, but have a requirement to update a 2nd table based on Insert, Update and Delete to one main table.

So when PS_DEPT_TBL has either update, insert or delete action, I need it to update PS_IWAY_CTL table. The columns on PS_IWAY_CTL table include:

TABLENAME (IE.PS_DEPT_TBL)
PRIMARY_KEY_1
ACTION (INSERT, UPDATE, DELETE)
DATE (CURRENT DATE AND TIME)


The Primary key on PS_DEPT_TBL is SETID.

To begin:

CREATE TRIGGER PS_DEPT_TBL_TRG
ON HR83PTST.PS_DEPT_TBL
AFTER INSERT, UPDATE, DELETE
AS

appreciate input
phsatech
New Member
New Member

--
06 Dec 2007 11:14 AM
Thnxs this worked pretty good. Is there a way to incorporate the current time into the date field (along with the date)? I couldn't find a 'getdate' option online.

thnxs again!
phsatech
New Member
New Member

--
07 Dec 2007 11:51 AM
I fixed the time/date issue by changing the data type. So that is all good.

Currently "Primary_Key_1" column is updated with SETID key. I'd like to modify the trigger so that I can insert on 2 more keys (DEPTID and EFFDT). So Primary_Key_1 = SETID' (currently working), and add Primary_Key_2 =DEPTID, and Primary_Key_3=EFFDT

That would be greatly appreciated. Then I can use that to help create 3 other triggers.

You are not authorized to post a reply.

Acceptable Use Policy