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 > Federate Server Triggers for Insert and Update

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-09, 15:21
pulsarcu pulsarcu is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
Federate Server Triggers for Insert and Update

Hi All,

I need help/suggestion on creating trigger on federated server.

Issue:

I have 2 databases in different servers(db2). I need a trigger whenever TABLE1 in DB1 is inserted I need the same to be inserted in TABLE2 in DB2. I have created nickname for the TABLE2 of DB2 in DB1 but I couldn't create a trigger for inserting record through nickname.

My trigger is kinda:

CREATE TRIGGER test_insert AFTER INSERT ON TABLE1 REFERENCING NEW AS insertrow FOR EACH ROW MODE DB2SQL BEGIN ATOMIC INSERT INTO nickname.TABLE2 (name1) VALUES (insertrow.name); END

while creating trigger it is showing error as : Operation not allowed for the federated environment reason code 21 , 22.

Please help me in making it out by trigger or through any other way.


Regards
Michael
Reply With Quote
  #2 (permalink)  
Old 03-05-09, 16:16
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Create a view that cover just the federated table nickname. Then insert into the view.

Andy
Reply With Quote
  #3 (permalink)  
Old 03-05-09, 23:16
pulsarcu pulsarcu is offline
Registered User
 
Join Date: Mar 2009
Posts: 2
Hi Andy,

Thanks for your quick response.

Do you want to create a VIEW for the nickname(table) created and through trigger insert into the VIEW which will actually insert into the table in another DB.

Is it possible to insert into VIEW through trigger ?


Regards
Michael
Reply With Quote
  #4 (permalink)  
Old 03-05-09, 23:22
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Yes, that is correct.

Andy
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