dynamic SQL Query

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
saha
Member
Posts: 1
Joined: Wed Apr 29, 2009 11:46 am

dynamic SQL Query

Post by saha » Wed Apr 29, 2009 11:50 am

Hi, i have a table "LOOKUP". i want to query this table using a dynamic IN clause like below
Select name_cd,rank from LOOKUP where rank =(select min(rank) from LOOKUP where name_cd IN('A','B').

My question is, instead of 'A' and 'B' i have to use variables dynamically from my program which used DCLGEN variables.

how do i fetch my rows now?

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Wed Apr 29, 2009 2:53 pm

try using...

Select name_cd,rank from LOOKUP where rank =(select min(rank) from LOOKUP where name_cd IN( :H-A,:H-B).
Natarajan
Chennai

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others