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 > trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-12-04, 09:44
lullo lullo is offline
Registered User
 
Join Date: Nov 2003
Posts: 20
Exclamation trigger

hello people,
i should create a trigger that insert the record in ADMIN.ANAMAGA_TMP after an insert in my table ADMIN.ANAMAGA. the db i db2 version 7. can you help me thanks thi is my code:
CREATE TRIGGER ADMIN.REPLICA AFTER INSERT ON ADMIN.ANAMAGA REFERENCING NEW AS n FOR EACH ROW MODE DB2SQL INSERT INTO
ADMIN.ANAMAGA_TMP
(
CODICE
)
VALUES
(
'codice'
)
but my result in ADMIN.ANAMAGA_TMP in the column CODICE is codice and not a value for example 1223.

anamaga is composed from
CODICE DESCRIZION TIPO
anamaga_temp is equal to anamaga (the some column).
when I insert a new one row in anamaga i would like to insert the row in anamaga_tmp in order to extract only new data.

Last edited by lullo; 07-12-04 at 11:42.
Reply With Quote
  #2 (permalink)  
Old 07-12-04, 11:24
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
What are you inserting into ADMIN.ANAMAGA and what do you want to appear in ADMIN.ANAMAGA_TMP. Please include the layouts of the two tables.

Andy
Reply With Quote
  #3 (permalink)  
Old 07-12-04, 11:52
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
The way I read what you want is that ADMIN.ANAMAGA_TMP is a log of only the new rows added to ADMIN.ANAMAGA. If this is true, then your trigger would be:

CREATE TRIGGER ADMIN.REPLICA AFTER INSERT ON ADMIN.ANAMAGA REFERENCING NEW AS n FOR EACH ROW MODE DB2SQL INSERT INTO
ADMIN.ANAMAGA_TMP VALUES (n.CODICE,n.DESCRIZION,n.TIPO)

Andy
Reply With Quote
  #4 (permalink)  
Old 07-13-04, 03:57
lullo lullo is offline
Registered User
 
Join Date: Nov 2003
Posts: 20
thanks andy it's running
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