A Better Way to Get Query/400 Definitions?
May 31, 2002 Timothy Prickett Morgan
Hey, Ted:
I am writing in response to your article, “Print Query Defintions from a Batch Job” that was published in the May 22 issue of Midrange Guru, OS/400 Edition.
A better solution is to use the Retrieve Query Management Query (RTVQMQRY) command, which works fine for a Query/400 definition (*QRYDFN object).
This puts the output into a source file that can be manipulated with a program.
See the following example:
PGM PARM(&LIBRARY) DCL VAR(&LIBRARY) TYPE(*CHAR) LEN(10) DCLF FILE(DSPOBJD) CLRPFM FILE(RTVQRYOUT) DSPOBJD OBJ(&LIBRARY/*ALL) + OBJTYPE(*QRYDFN) + OUTPUT(*OUTFILE) + OUTFILE(QTEMP/DSPOBJD) OVRDBF FILE(QTXTSRC) + TOFILE(QGPL/QTXTSRC) + MBR(RTVQRYTMP) LOOP: RCVF RCDFMT(QLIDOBJD) MONMSG MSGID(CPF0864) + EXEC(GOTO CMDLBL(ENDLOOP)) RTVQMQRY QMQRY(&ODLBNM/&ODOBNM) + SRCFILE(QGPL/QTXTSRC) + SRCMBR(RTVQRYTMP) ALWQRYDFN(*YES) CALL PGM(RTVQRY1) PARM(&ODOBNM) GOTO LOOP ENDLOOP: ENDPGM
This is what I use. I wrote the RTVQRY1 program to read the QTXTSRC file
which uses my rtvqryout file for my specific output.
— Jay
Thanks for the email. Your code gets the SQL statement that generates the query, preceded by some Query Management definition codes. It does not get the definition you get when you use option 6 of the Work with Queries (WRKQRY) command. What you’re doing is good and useful, but it’s not the same thing that I published.
— Ted
Sponsored By Advanced Systems Concepts |
SEQUEL meets all your iSeries and AS/400 data access needs in a single, integrated solution:
Take 6 minutes to For more information or a FREE trial of SEQUEL, |