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
 
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: 6970
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: 6970
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: 6970
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 Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am

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