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

Use of 0<>0 in DB2 Sql..


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

New User


Joined: 23 Nov 2006
Posts: 22
Location: India

PostPosted: Wed Apr 09, 2008 3:18 am
Reply with quote

Hi, I have a COBOL program using the below SQL ,
SELECT EMP_NAME,EMP_LOC
FROM COMP_DET
WHERE (EMP_ID = :T00-EMP-ID
OR 0<>0)

Can you please help me out what is the purpose of '0<>0' condition in the WHERE clause.
FYI: Data type for EMP_ID is Integer.

Thanks in Advance.
Back to top
View user's profile Send private message
yogalakshmi

New User


Joined: 20 Sep 2007
Posts: 17
Location: cheenai

PostPosted: Wed Apr 09, 2008 10:12 am
Reply with quote

If there is any index (say A) on EMP_ID, providing constraints like 0<>0,0=1 will force the optimizer not to choose that index(A) for the indexed access. In this case, as there is only one predicate that too on EMP_ID providing 0<>0 would lead to table space scan even though the indexed access is possible (by A).
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Wed Apr 09, 2008 8:43 pm
Reply with quote

Hi Natinuk,

This might be a good piece of information for you:

http://www.ibmdatabasemag.com/story/showArticle.jhtml?articleID=12803232

Thanks,
Prajesh
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

 


Search our Forums:

Back to Top