If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > replication target trigger not firing

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-03-04, 18:38
craigmc craigmc is offline
Registered User
 
Join Date: Aug 2003
Location: austin,tx
Posts: 90
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
Reply With Quote
  #2 (permalink)  
Old 06-04-04, 01:39
Tony Winch Tony Winch is offline
Registered User
 
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?
Reply With Quote
  #3 (permalink)  
Old 06-04-04, 09:33
craigmc craigmc is offline
Registered User
 
Join Date: Aug 2003
Location: austin,tx
Posts: 90
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.
Reply With Quote
  #4 (permalink)  
Old 06-04-04, 16:17
craigmc craigmc is offline
Registered User
 
Join Date: Aug 2003
Location: austin,tx
Posts: 90
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.
Reply With Quote
  #5 (permalink)  
Old 06-05-04, 07:36
Tony Winch Tony Winch is offline
Registered User
 
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On