View previous topic :: View next topic
|
Author |
Message |
srinut123
New User
Joined: 11 Oct 2005 Posts: 62 Location: India
|
|
|
|
Hi
I've a requirement..
When An insert or delete happens on table A,
-> if A.Field 1 is avalable in Table "B",
--> check if A.Field 2 is available in Table "C".. If INSERT, insert it into table "C" .. if "DELETE", delete it from table "C".
Can we accomplish this with DB2 triggers? I'm poor in this..
Thanks
Sri |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
What does available mean in this question?
It will probably help if a more "real" example is shown rather than alphabet soup.
Database activity can activate a trigger, but i am not sure how to relate this to the "availability" of these "fields" (columns maybe?). |
|
Back to top |
|
|
srinut123
New User
Joined: 11 Oct 2005 Posts: 62 Location: India
|
|
|
|
Hi
Here is an example..
Code: |
TABLE A:
COMP LOC-ID DESC FILED 3 FIELD 4 ...
A100 9991221 TEST1 X X
A100 9991223 TEST1 X X
A101 8991221 TEST1 X X
A101 8991222 TEST1 X X
TABLE B:
COMP TYPE
A100 1
A101 2
A103 3
TABLE C:
COMP LOCID FILED 5 FIELD 6
A100 9991221 X X
A100 9991222 X X
A101 8991221 X X
A101 8991222 X X |
COMP code and LOCID in Table C should be available in Table "A"..
There is no problem when we do an initial load.. but in the future, if a LOCID is inserted or deleted from Table "A",
if COMP associated with LOCID inserted or deleted is in Table "B", then we have to insert/delete that into Table "C" (getting data for Field5 and Field 6 from other tables).. if COMP associated with LOCID inserted or deleted is not in Table "B".. we can just ignore it..
I wanted to check if it is possible to do this thru Triggers.. as we dont want to go for a new program and schedule another job..
Thanks |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
|