Passing parameter to Query Manager

150 pts.
Tags:
AS/400
CLP
CLPROGRAM
Query Manager
V5R4
V5R4M0
I have the following query manager that errors with the following statement that is being placed in the CLP program: Type a value for variable "SELECT" and press Enter. This value should have been passed by the CLP program: *************** Beginning of data ************************************ PGM DCL VAR(&SELEC) TYPE(*CHAR) LEN(5) CHGVAR VAR(&SELEC) VALUE('54310') STRQMQRY QMQRY(AXMTESTLIB/TESTQM) QMFORM(*SYSDFT) + ALWQRYDFN(*YES) SETVAR((CUST &SELEC)) ENDPGM ****************** End of data *************************************** Type SQL Statement ************************** Beginning of Data ************************* 0001.00 select name, addr, city, state, zip, cust 0002.00 from cusrec 0003.00 where cust = &SELECT ***************************** End of Data **************************** *************** Beginning of data ************************************* A R CUSRECR TEXT('MASTER FILE') A CUST 5A TEXT('CUSTOMER #') A NAME 20A TEXT('NAME') A ADDR 20A TEXT('ADDRESS') A CITY 20A TEXT('CITY') A STATE 2A TEXT('STATE') A ZIP 5P 0 TEXT('ZIP') A SRHCOD 6A TEXT('SEARCH') A CUSTYP 1A TEXT('TYPE') A ARBAL 10P 2 TEXT('BALANCE') ****************** End of data **************************************** CUST NAME ADDR CITY 12345 ABC 2535 MAIN ST ST. PETERSBURG 54310 BBC 2536 MAIN ST ST. PETERSBURG 30606 CHANGED 30606 ADDRESS FOR 30606 ST. PETERSBURG 30607 COPY RECORD ADDRESS FOR 30607 ST. PETERSBURG 30608 ADD RECORD ADDRESS FOR 30608 ST. PETERSBURG ******** End of report ******** How can I run this process without prompting for the variable? Help! Sorella

 



Software/Hardware used:
AS/400 V5R4M0
ASKED: August 31, 2010  12:57 PM
UPDATED: September 7, 2010  5:11 PM

Answer Wiki

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

<i>How can I run this process without prompting for the variable?</i>

You bypass prompting by supplying values for the replacement variables. In your example, you pass in a value for a replacement variable named &CUST; but the only replacement variable in your QM query is named &SELECT.

You might change your STRQMQRY SETVAR() parameter to be:<pre>
SETVAR(( SELECT &SELEC ))</pre>
Or you might change your QM query to be:<pre>
where cust = &CUST</pre>
Change one or the other (or both) so that they match.

Note that replacement variable names are case-sensitive; that is, &SELECT is different from &select. Also note that quotes around replacement variables must be supplied by your program; that is, if column CUST is a CHAR column, your program <b>must</b> supply quotes before the QM query can run — you <b>cannot</b> have your QM query look this way:<pre>
where cust = ‘&SELECT’</pre>
If you code that way, the &SELECT replacement variable will be assumed to be a literal constant rather than a replacement variable; it won’t be replaced with a value.

Tom

Discuss This Question: 1  Reply

 
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
  • a1maida
    It worked! Thanks
    150 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