Calling query/400 through CL

185 pts.
Tags:
CL
Query/400
Hi,

Is it possible to call query/400 through a CL program?

Please suggest some idea..

Thanks,

Jayashree V.

 

 

 



Software/Hardware used:
AS/400

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 12  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • philpl1jb
    That would be the RUNQUERY command in CL
    51,355 pointsBadges:
    report
  • CharlieBrowne
    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.
    41,430 pointsBadges:
    report
  • DanTheDane
    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
    2,555 pointsBadges:
    report
  • VJayashree
    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
    185 pointsBadges:
    report
  • CharlieBrowne
    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.
    41,430 pointsBadges:
    report
  • devan
    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...
    390 pointsBadges:
    report
  • philpl1jb
    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
    51,355 pointsBadges:
    report
  • Teandy
    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)
    
    
    5,860 pointsBadges:
    report
  • DanTheDane
    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 */
    ENDPGM
    
    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. Happy coding. DanF
    2,555 pointsBadges:
    report
  • Mrnaturl
    You're looking for something like this: OVRPRTF FILE(QPQUPRFIL) OUTQ(XEROX_2) RUNQRY QRY(QRYLIB/DLYTRANS01) DLTOVR FILE(QPQUPRFIL)
    145 pointsBadges:
    report
  • DanTheDane
    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 */
    ENDPGM
    
    I can confirm that Teandys tip on printing the output works. DanF
    2,555 pointsBadges:
    report
  • philpl1jb
    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
    51,355 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following