Midrange News for the IBM i Community


Posted by: WestCoastGuy
CL command to print wrkqry definition
has no ratings.
Published: 21 Oct 2011
Revised: 23 Jan 2013 - 4103 days ago
Last viewed on: 18 Apr 2024 (11246 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

CL command to print wrkqry definition Published by: WestCoastGuy on 21 Oct 2011 view comments(2)

When I display a list of queries created by the wrkqry command, one of the command options is '6', to print the query definition.

 

Is there a command that I could use in a CL program - or at the command line - that I could use with a driver file to print the query definitions for all of the queries that are named in the driver file?

Or am I stuck using '6' for every query in the library, to print the definitions?

 

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: CL command to print wrkqry definition
Posted: 12 years 5 months 29 days 11 hours 45 minutes ago
Edited: Fri, 21 Oct, 2011 at 09:31:56 (4563 days ago)

See "Query for i5/OS", V6R1, SC41-5210-05, Ch. 16. Basically, you can WRKQRY opt 6, you can print it as you exit when creating or changing, or on RUNQRY use PRTDFN(*YES). The problem with RUNQRY PRTDFN() is you are actually running the query, too, so not real useful.

But what are you trying to accomplish?

Do you have SQL installed, which also includes Query Manager? You could RTVQMQRY with ALWQRYDFN(*YES or *ONLY), which retrieves the *QRYDFN into a source member. QM format has some cryptic codes, but there's a plainly visible SELECT statement, which gives you tables, columns, and selection criteria. It won't give you report layout.

If all you need to know is what files are referenced, that's available from *QRYDFN objects as of V6R1. Just DSPPGMREF mylib/myqry OBJTYPE(*ALL or *QRYDFN). Also see PTF SI34166; it provides a program that adds the file usage info to queries create prior to V6R1.

Posted by: DeepakD
Premium member *
India
Comment on: CL command to print wrkqry definition
Posted: 12 years 5 months 15 days 13 hours 54 minutes ago

 

0001.00              PGM        PARM(&LIB)
0002.00              DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)
0003.00              DCLF       FILE(MyLib/Outfile) RCDFMT(QLIDOBJD)
0004.00              CLRPFM     FILE(MyLib/Outfile)
0005.00              CLRPFM     FILE(MyLib/YourSRCPF) MBR(QRYLIST)
0006.00              DSPOBJD    OBJ(&LIB/*ALL) OBJTYPE(*QRYDFN) +
0007.00                           OUTPUT(*OUTFILE) OUTFILE(MyLib/QRYLIST1)
0008.00  NEXT:       RCVF       RCDFMT(QLIDOBJD)
0009.00              MONMSG     MSGID(CPF0864) EXEC(GOTO CMDLBL(END))
0010.00              RTVQMQRY   QMQRY(&ODLBNM/&ODOBNM) +
0011.00                           SRCFILE(MyLib/QQRYSRC) ALWQRYDFN(*ONLY)
0012.00              CPYF       FROMFILE(MyLib/QQRYSRC) +
0013.00                           TOFILE(MyLib/QQRYSRC) FROMMBR(&ODOBNM) +
0014.00                           TOMBR(QRYLIST) MBROPT(*ADD)
0015.00              GOTO       CMDLBL(NEXT)
0016.00  END:        ENDPGM

I use above program to get a list/definition of all queries in a single SRC file (QQRYSRC) as well as the definition of all queries into a single source [MyLib/QRYLIST(QRYLIST)]

HTH

Deepak