Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Location
    austin,tx
    Posts
    104

    Unanswered: replication target trigger not firing

    Hello, I'm fairly new to the DB2 world. Here's my problem, I'm replicating data from a laptop running DB2 PE 8.1.5 to a server running DB2 UDB 8.1. The target table has an insert trigger defined on it, but it doesn't appear to fire when data is replicated in.
    If I run an insert stmt on the target directly, the trigger fires. If I run the same insert stmt on the source, then replicate the data over, the data is inserted at the target, but the trigger does not fire.
    Are there any limitations or gotchas with triggers and replication?

    Here is the trigger if it makes a difference:
    CREATE TRIGGER SIDS.GI_TRIGG_INS
    NO CASCADE BEFORE INSERT ON SIDS.GI_GEN_INFO
    REFERENCING NEW AS inserted
    FOR EACH ROW
    MODE DB2SQL
    BEGIN ATOMIC
    SET inserted.TESTFIELD = 'BLAAAAA';
    END

    Thanks.
    -Craig

  2. #2
    Join Date
    Jun 2002
    Posts
    7

    Incremental or Refresh

    Craig,

    Not an answer but some questions..

    Are you using incremental or refresh for the replication?

    Have you tried starting an event monitor while apply runs just to double check the insert is occuring as you suspect?

  3. #3
    Join Date
    Aug 2003
    Location
    austin,tx
    Posts
    104
    Thanks for the reply Tony. I haven't tried setting up an event monitor yet, although it sounds like a good suggestion.

    I didn't actually set up the replication, but here's my understanding of it. There are many sources (laptops) and a single target (central server). Technically the replication is bidirectional, but it is filtered so each laptop only has it's own set of data that it initially inserted. The replication is transactional.

    So, I want to insert a record on a laptop, have it replicate to the central server. When it is inserted on the central server, I want a trigger there to fire and update some state information. The central server contains the 'master' copy of the data.

  4. #4
    Join Date
    Aug 2003
    Location
    austin,tx
    Posts
    104
    After much testing, I think I have discovered the problem.

    The table I'm inserting into has both an INSERT and an UPDATE trigger defined on it at the target.
    From the source, if I just perform an insert, then replicate it, the INSERT trigger on my target table fires.

    BUT....
    If I do an insert, followed by an update at the source, then force replication, the INSERT trigger at my target does not fire, only the UPDATE trigger fires.

    This doesn not seem like what the correct behavior should be, but that is what I am observing.

  5. #5
    Join Date
    Jun 2002
    Posts
    7

    Sounds right

    Craig,

    There is a setting under replicate to condense changes so your update is sufficient to replicate the insert. Can't remember the field but you can ask replication to replay all transactions to get a complete history. The condense option is obviously there to give replication better performance.

    Though in the back of my mind I can't help but feel you need at least one insert to happen otherwise your row will never exist to update.

Posting Permissions

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