Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Query on DB2 Triggers

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
srinut123

New User


Joined: 11 Oct 2005
Posts: 62
Location: India

PostPosted: Tue Apr 20, 2010 9:53 am    Post subject: Query on DB2 Triggers
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue Apr 20, 2010 10:17 am    Post subject:
Reply with quote

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
View user's profile Send private message
srinut123

New User


Joined: 11 Oct 2005
Posts: 62
Location: India

PostPosted: Tue Apr 20, 2010 11:22 am    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 20, 2010 11:43 am    Post subject:
Reply with quote

what you mean by available is constraints.

by your vocabulary, it is obvious that you have not bothered to read the manual.

the answer to you question - can it be done by triggers - yes.

how to do it can be found in the following:

DB for z/OS Application Programming Topics

a list of 23 Redbooks that are applicable

Application programmers manual and SQL Reference for the db2 version that you are using

An Article about creating DB2 Triggers
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us