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

Using IN with this query?


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

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Feb 18, 2009 7:40 pm
Reply with quote

Hi,

I have written below query in SPUFI to fetch details from a table in our DB successfully.

Code:

SELECT * FROM DM01.ORDER                           
 WHERE (ORD_KEY,ORD_NBR) = ('X42','    XXXX42')
    OR (ORD_KEY,ORD_NBR) = ('X43','    XXXX43')
WITH UR;                                                   


I would like to know how to use IN instead of writing it separately?

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

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed Feb 18, 2009 8:36 pm
Reply with quote

In this case, you can't use IN
If you had:
Code:
WHERE (ORD_KEY,ORD_NBR) = ('X42','    XXXX42')
   OR (ORD_KEY,ORD_NBR) = ('X42','    XXXX43')
then you could use
Code:
WHERE ORD_KEY = 'X42' AND ORD_NBR IN ('    XXXX42','    XXXX43')
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Feb 18, 2009 10:03 pm
Reply with quote

Your where clause can be broken down as

Code:


WHERE

(ORD_KEY = 'X42' AND ORD_NBR = '    XXXX42' )

OR

(ORD_KEY = 'X43' AND ORD_NBR = '    XXXX43' )



cannot use IN clause here ...
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Feb 19, 2009 3:38 pm
Reply with quote

In fact, I tried:
Code:
WHERE (ORD_KEY,ORD_NBR) IN ( ('X42','    XXXX42') , ('X43','    XXXX43') )
but couldn't make it work.
SQLCODE -216 that I received when playing with the values leads me to think that something like that may be possible.
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Thu Feb 19, 2009 4:31 pm
Reply with quote

Guys, thanks for all your replies.
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top