-1

I was trying to execute a IBM DB2 query using runqry command of CLLE, but was unable to do it as it contained a where condition and I was unable to define a host variable in the runqry command. Can this be done by using the runqry command without using qryslt.

Please help me out.

yuvi
  • 13
  • 3

1 Answers1

0

RUNQRY does not support variables.

You can define variables in the Query/400 query, but you must use the Start Query Management Query (STRQMQRY) command to run the query.

Be sure to specify:

Allow information from QRYDFN  . ALWQRYDFN  *YES`

Here's an IBM document that shows how to do it.

                        Select Records                                      
   Type comparisons, press Enter.  Specify OR to start each new group.     
     Tests: EQ, NE, LE, GE, LT, GT, RANGE, LIST, LIKE, IS, ISNOT...        

   AND/OR  Field      Test    Value (Field, Number, 'Characters', or ...)  
          GLCOMP     EQ      :COMPANY                                      
   AND    GLBRAN     EQ      :BRANCH                                       
   AND    GLACC      EQ      :ACCOUNT                                       
  -----------------------------------------------------------------------
STRQMQRY QMQRY(library/qry-name) ALWQRYDFN(*YES) +
QMFORM(*QMQRY) SETVAR((COMPANY 1) (BRANCH 1) (ACCOUNT 12000)) 
Charles
  • 21,637
  • 1
  • 20
  • 44
  • You can also use & to denote a variable in qmqry but this would be for actual qmqry created with CRTQMQRY. – danny117 Nov 14 '17 at 18:25