Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 6968
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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us