Results 1 to 2 of 2

Thread: DB2 trigger

  1. #1
    Join Date
    Jan 2005

    Unanswered: DB2 trigger

    My first trigger.
    1) I want to keep track of all Add, Update and Delete of a DB2 Master file by sending some info to others DB2 files. My trigger is set for After for all 3 instances. If I do a Delete should the record going to my new DB2 be blank? Should it be blank if I also set the Trigger for Before?
    The trigger start an RPGILE program that check for TEVENT. I was hoping that the DELETE would populate the new file with the records being deleted without having to verify for the TEVENT and select the OLD_RECORD.
    2) If my master is being updated from different application, is a trigger the best way to keep track of changes being made to it?
    3) Can the trigger be started at a specific time of day. (once a day)
    Thank you.

  2. #2
    Join Date
    Jan 2005
    1a) A trigger can be for update, insert **OR** delete - not all three. You need three triggers - note the plural.
    1b) on a delete trigger use REFERENCING OLD; on a new trigger use REFERENCING NEW; what do you want to do with an update trigger?
    2) a trigger is the only way to be certain of capturing all changes.
    3) a trigger is fired when the alteration occurs; you can't pospone it to some later time. You can, however, use the trigger to populate a "to be processed" table and then process that table at a later time.

    James Campbell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts