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

How to know which condition true and which false in WHEN


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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: 2146
Location: At my coffee table

PostPosted: Fri Nov 02, 2007 11:53 pm
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

Moderator Emeritus


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

PostPosted: Sat Nov 03, 2007 12:17 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
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