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
 

 

Dynamic where clause.

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

New User


Joined: 24 Jul 2007
Posts: 18
Location: india

PostPosted: Mon Jun 14, 2010 8:16 pm    Post subject: Dynamic where clause.
Reply with quote

Hi,

Please consider following querry.

Select *
From table T
Where A = Var1 and
B = Var2.

Now if I have a scenario where I get Value for only Var1 and in another scenario for value for only VAR2. Is there a way to accomplish all 3 scenarios in a single query? Or I have to use 3 different queries like

Select *
From table T
Where A = Var1

Select *
From table T
Where A = Var2

Select *
From table T
Where A = Var1 and
B = Var2.

Please Suggest.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jun 14, 2010 9:40 pm    Post subject:
Reply with quote

why the demand for only 1 complex query?

using cobol flow control instructions
would enable an optimum query to be invoked.

otherwise, you are making the query complex
and 'slower' - more db2 resource intensive.

the extra seconds for the cobol to decide which query to use
would have a smaller impact on the machine - thus more time for others
than a complex query.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jun 15, 2010 1:26 am    Post subject:
Reply with quote

Quote:
Or I have to use 3 different queries like
Select *
From table T
Where A = Var1

Select *
From table T
Where A = Var2

Select *
From table T
Where A = Var1 and
B = Var2.


it is hard to take people seriously,
when they can not even bother to be precise with their requirements.

but one example is here
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Tue Jun 15, 2010 5:40 am    Post subject:
Reply with quote

Or, If you are into dynamic sql, then this
Redbook - Squeezing the Most Out of Dynamic SQL with DB2 for z/OS and OS/390
is possibly what you are looking for...
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 Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Need to create file with Dynamic Name... kapil27 JCL & VSAM 4 Wed May 25, 2016 9:45 am


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