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
 

 

How to know which condition true and which false in WHEN

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

New User


Joined: 03 Nov 2005
Posts: 19

PostPosted: Fri Nov 02, 2007 10:56 pm    Post subject: How to know which condition true and which false in WHEN
Reply with quote

Hi,

I have different situation..

SELECT * FROM TABLE EMP
WHERE A = '10' AND
B = '20' AND
C = '30'

Table values for A,B,C are 10, 20, 40.
So obviously my query will return '100', here I know that third condition fails because '30' not matching with table C value '40' and rest the two are TRUE. Is there any thing know about this from query it self, means in WHERE because of which condition we received '+100'.

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

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Nov 02, 2007 11:16 pm    Post subject: Re: How to know which condition true and which false in WHEN
Reply with quote

deva wrote:
Hi,

I have different situation..

SELECT * FROM TABLE EMP
WHERE A = '10' AND
B = '20' AND
C = '30'

Table values for A,B,C are 10, 20, 40.
So obviously my query will return '100', here I know that third condition fails because '30' not matching with table C value '40' and rest the two are TRUE. Is there any thing know about this from query it self, means in WHERE because of which condition we received '+100'.

Deva..


No there is nothing that will tell which condition caused the not found, it would be possible (maybe not in you case) for multiple conditions to cause a not found.
Back to top
View user's profile Send private message
deva

New User


Joined: 03 Nov 2005
Posts: 19

PostPosted: Fri Nov 02, 2007 11:41 pm    Post subject: Reply to: How to know which condition true and which false i
Reply with quote

Is it possible to get for at least one condition , means is because of A='10' or not, no need to know about other two conditions but those two should be in query.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Fri Nov 02, 2007 11:53 pm    Post subject:
Reply with quote

Use OR instead of AND and you will know that at least one of the conditions is true....Then check for yourself to see if all are true and/or which are false.....
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: Sat Nov 03, 2007 12:17 am    Post subject:
Reply with quote

Hello,

Keep in mind that if multiple rows might be returned to your program, you will want to use a cursor. If a simple select returns multiple rows to your program, you will get a -811 return code from db2.
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
This topic is locked: you cannot edit posts or make replies. Need help on If condition continuatio... ashok_uddaraju CLIST & REXX 4 Fri May 19, 2017 8:55 am
No new posts Joinkeys with condition scdinesh DFSORT/ICETOOL 10 Tue Feb 14, 2017 12:20 am
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts INCLUDE condition questions van bui DFSORT/ICETOOL 1 Thu Jun 30, 2016 9:52 am
No new posts 2 vsam file compare and update a fiel... ABINAYATHULASI DFSORT/ICETOOL 6 Sun May 29, 2016 11:15 am


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