IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need a solution regarding WHERE condition


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sreenigacc

New User


Joined: 16 Oct 2007
Posts: 15
Location: bangalore

PostPosted: Thu Sep 25, 2008 11:24 am
Reply with quote

The current scenario is in a cobol+db2 program is like this

DELETE FROM TABLENAME
WHERE NAME = :WS-NAME
AND (COMPANY = 'A' OR
COMPANY = 'B')

OR

SELECT X, Y, Z FROM TABLENAME
WHERE NAME = :WS-NAME
AND (COMPANY = 'A' OR
COMPANY = 'B')


In future if we need to add one or more values in COMPANY column(We know that some more companys will add like 'C' , 'D' etc..), then again we need to change this cobol+db2 program.

instead of changing the program again and again, any one can help me out on this.

(what I am seeking for this is instead of changing in program, can we handle this scenario with DB2 tables or corporate tables etc...)
thanks in advance
sreeni
Back to top
View user's profile Send private message
zero

New User


Joined: 01 Dec 2007
Posts: 21
Location: Hyderabad

PostPosted: Thu Sep 25, 2008 11:53 am
Reply with quote

Hi Sreeni,
i had the same type of scenario some time back. You asked whether this can be achieved by using some db2 Table. Yes, we can, provided we have a table which can contain all the possible values for 'COMPANY' field.

Assume, we have a table "CODE_TABLE" with the following data :

CODE_NAME CODE_VALUE
COMPANY A
COMPANY B


Code:
DELETE
FROM      TABLENAME
WHERE    NAME = :WS-NAME
AND        COMPANY IN (SELECT  CODE_VALUE
                                   FROM     CODE_TABLE
                                   WHERE   CODE_NAME = 'COMPANY');
The above query will serve as a solution to your Query.
Now, we no do not have to change the program. we just need add new values to the CODE_TABLE.

if you have any table like the above, it will be fine.

One more possible solution i can think of is Dynamic Queries.
we can have all the possible values for COMPANY in a File or we can send them thru PARM in the JCL. after reading these values in the program, we can create a query.


Thanks,
...
Back to top
View user's profile Send private message
sreenigacc

New User


Joined: 16 Oct 2007
Posts: 15
Location: bangalore

PostPosted: Thu Sep 25, 2008 2:15 pm
Reply with quote

Hi,

first of all thank you very much for your valuable suggestions and you are correct, if we use a DB2 table.

here my concers are
1)There is no DB2 table for this company code as of now. so is it proper way to create a DB2 table with these columns company code and compay indicator.

2) Currently we are using Corporate tables, which will store the above data but the problem is we can't use them as a db2 query. these corporate tables are called by a service(program) and finally it throws a record with all the values of a particular record in that table.

3) If you have any idea about coporate tables please provide me the suggestions and let me know...........

I appreciate your help
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Thu Sep 25, 2008 8:25 pm
Reply with quote

Hello,

You might consider accessing the corporate tables directly rather than using the service program. . .
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts SDSF like solution in EJES (store com... All Other Mainframe Topics 4
No new posts How to give complex condition in JCL . CLIST & REXX 30
No new posts selectively copy based on condition DFSORT/ICETOOL 3
This topic is locked: you cannot edit posts or make replies. Control-m JOB executing even when the... Compuware & Other Tools 6
No new posts Dynamic condition checks COBOL Programming 5
Search our Forums:

Back to Top