Hi,
We can use RunQry command. But i want to call a query file from a Control Language Program.
Jayashree V.
Doesn't the runqry command have the query file and library as the first parameter? Alternatively if you wan to query a file without creating a query then you can use runqry *n flielib/file rcdslt(*yes)
Alternativelty if yuo want to satrt getting really sophisticated then have a look at Query Manager as that will allow you to dynamically build a query programmatically.
Last Wiki Answer Submitted: January 11, 2012 2:46 pm by VJayashree185 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
I am having a hard time understanding what you are asking.
In a CL, you run a query that has allready been created by using RUNQRY (yourquery)
or dynamically to just do a singel file by RUNQRY *N (yourfile)
If this does not help you, please give us more information.
RUNQRY is the command to use. Try RUNQRY + F4-key to study parameters. Especially note your options to ‘overwrite’ definitions inside your query, by adding parameters to command.
My requirement is I want to call the created query/400 program through a control language program so that the query ll run and the output file will be stored in a location mentioned in the control language program
Note 1: Since you cannot pass variable filename and library for the query outputfile, then leave the default (QTEMP/QQRYOUT) in your Query400 object. If you do that this RUNQRY will run and output the file QTEMP/QPQUPRFIL.
Note 2: Renames the QTEMP/QPQUPRFIL into your chosen filename, still located in QTEMP.
Note3: Now move the file to the library of your choice.
Remember this code is just a sketch; – you should add some MONMSG a.o. before putting into production.
If you create a command you may pass all the parameters to the CL.
That would be the RUNQUERY command in CL
I am having a hard time understanding what you are asking.
In a CL, you run a query that has allready been created by using RUNQRY (yourquery)
or dynamically to just do a singel file by RUNQRY *N (yourfile)
If this does not help you, please give us more information.
RUNQRY is the command to use. Try RUNQRY + F4-key to study parameters. Especially note your options to ‘overwrite’ definitions inside your query, by adding parameters to command.
DanF
Hi All,
Thanks for your update.
My requirement is I want to call the created query/400 program through a control language program so that the query ll run and the output file will be stored in a location mentioned in the control language program
Jayashree V
Sounds like you want to build something on-the-fle.
I’d suggest you use SQL.
You can build a source member and then do a RUNSQLSTM to execute it.
Hi
Depending on your requirements you can run a query using vairaibles or without.. you can also run this via batch mode. The options are plenty…
So .. you want to run myqry in mylib and put the results in the cl variables
&MYLIB and &MYOUTF .. that would be something like this ..
RUNQRY QRY(MYLIB/MYQRY) OUTTYPE(*OUTFILE) OUTFILE(&MYLIB/&MYOUTF)
Phil
and the output file will be stored in a location mentioned in the control language program
I am guessing you are talking about a spool file. If so, you can try something like this:
/*********************************************************************/ /* override the outq */ /*********************************************************************/ OVRPRTF FILE(QPQUPRFIL) OUTQ(My_Outq) /*********************************************************************/ /* run the qry */ /*********************************************************************/ RUNQRY QRY(My_Qry_Lib/My_Qry)This sketch program may help:
PGM DCL VAR(&QRYLIB) TYPE(*CHAR) LEN(10) VALUE('myqrylib') DCL VAR(&QRY400OBJ) TYPE(*CHAR) LEN(10) VALUE('myqryobj') DCL VAR(&RESULTFILE) TYPE(*CHAR) LEN(10) VALUE('myfile') DCL VAR(&MYLIB) TYPE(*CHAR) LEN(10) VALUE('mylib') RUNQRY QRY(&myqrylib/&myqryobj) OUTTYPE(*OUTFILE) /* note 1 */ RNMOBJ OBJ(QTEMP/QPQUPRFIL) OBJTYPE(*FILE) + NEWOBJ(&resultfile) /* note 2 */ MOVOBJ OBJ(QTEMP/&newname) OBJTYPE(*FILE) + TOLIB(&mylib) /* note 3 */ ENDPGMNote 1: Since you cannot pass variable filename and library for the query outputfile, then leave the default (QTEMP/QQRYOUT) in your Query400 object. If you do that this RUNQRY will run and output the file QTEMP/QPQUPRFIL.
Note 2: Renames the QTEMP/QPQUPRFIL into your chosen filename, still located in QTEMP.
Note3: Now move the file to the library of your choice.
Remember this code is just a sketch; – you should add some MONMSG a.o. before putting into production.
If you create a command you may pass all the parameters to the CL.
Happy coding.
DanF
You’re looking for something like this:
OVRPRTF FILE(QPQUPRFIL) OUTQ(XEROX_2)
RUNQRY QRY(QRYLIB/DLYTRANS01)
DLTOVR FILE(QPQUPRFIL)
Sorry, I had some mis-naming in my prev CL coe. Hee it is corrected:
PGM DCL VAR(&QRYLIB) TYPE(*CHAR) LEN(10) VALUE('qrplobj ') DCL VAR(&QRY400OBJ) TYPE(*CHAR) LEN(10) VALUE('q ') DCL VAR(&RESULTFILE) TYPE(*CHAR) LEN(10) VALUE('myfile') DCL VAR(&MYLIB) TYPE(*CHAR) LEN(10) VALUE('mylib') RUNQRY QRY(&QRYLIB/&QRY400OBJ) OUTTYPE(*OUTFILE) /* note 1 */ RNMOBJ OBJ(QTEMP/QPQUPRFIL) OBJTYPE(*FILE) + NEWOBJ(&resultfile) /* note 2 */ MOVOBJ OBJ(QTEMP/&resultfile) OBJTYPE(*FILE) + TOLIB(&mylib) /* note 3 */ ENDPGMI can confirm that Teandys tip on printing the output works.
DanF
Since you cannot pass variable filename and library for the query outputfile ???
— why??? not because a restrition of CL or Query/400
RUNQRY QRY(MYLIB/MYQRY) OUTTYPE(*OUTFILE) OUTFILE(&MYLIB/&MYOUTF)
works just fine.
Phil