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
 

 

Reg: SQL query

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

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Mon Sep 19, 2011 1:33 pm    Post subject: Reg: SQL query
Reply with quote

HI,

I have been using the following query to fetch all programs starting with YUGT.

Code:

SELECT A.NAME, HEX(CONTOKEN)                     
   FROM SYSIBM.SYSPACKAGE A                       
   WHERE NAME LIKE 'YUGT%' AND COLLID='YATCTTJH' 
   AND BINDTIME = (SELECT MAX(BINDTIME)           
   FROM SYSIBM.SYSPACKAGE B                       
   WHERE B.NAME=A.NAME                           
   AND COLLID='YATCTTJH')                         


It is working correctly.

But now i want to inlcude the program YUFU0000 in addition to YUGT* programs in the same query.

Kindly share your thoughts to achive this.

Thanks
R KARTHIK
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Mon Sep 19, 2011 1:36 pm    Post subject: Reply to: Reg: SQL query
Reply with quote

UNION ???
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 788
Location: Chennai, India

PostPosted: Mon Sep 19, 2011 1:42 pm    Post subject:
Reply with quote

Code:
SELECT A.NAME, HEX(CONTOKEN)                     
   FROM SYSIBM.SYSPACKAGE A                       
   WHERE (NAME LIKE 'YUGT%' OR NAME = 'YUFU0000') AND COLLID='YATCTTJH' 
   AND BINDTIME = (SELECT MAX(BINDTIME)           
   FROM SYSIBM.SYSPACKAGE B                       
   WHERE B.NAME=A.NAME                           
   AND COLLID='YATCTTJH') 


Hope it will work. But not sure that this one is an optimized way.. Sorry.
Back to top
View user's profile Send private message
karthikr44

Active User


Joined: 25 Aug 2007
Posts: 235
Location: Chennai

PostPosted: Mon Sep 19, 2011 3:20 pm    Post subject: Reply to: Reg: SQL query
Reply with quote

Hi Gnana Sekaran,

Before i post i actually tried the following code. But i got erroneous output. Same rows came multiple times. (may be due to join). Instead of expected 60 rows i got 853 rows.

Code:

SELECT A.NAME, HEX(CONTOKEN)                     
   FROM SYSIBM.SYSPACKAGE A                       
   WHERE NAME LIKE 'YUGT%' OR NAME = 'YUFU0000' AND COLLID='YATCTTJH' 
   AND BINDTIME = (SELECT MAX(BINDTIME)           
   FROM SYSIBM.SYSPACKAGE B                       
   WHERE B.NAME=A.NAME                           
   AND COLLID='YATCTTJH')


But when i put bracket like your code i get correct result.

Code:

WHERE (NAME LIKE 'YUGT%' OR NAME = 'YUFU0000') AND


Thanks
R KARTHIK
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 Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm


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