Passing variables from CL to QMQRY

95 pts.
Tags:
AS/400
CL Program
STRQMQRY
Hi, I have a CL that get parameter and run QMQRY. When I run it, I get a prompt: "Type a value for variable "x" and press enter". Why I get it even though I pass the parameter? The CL:
"

PGM PARAM(&X)

DCL VAR(&X) TYPE(*CHAR) LEN(8)

STRQMQR QMQR(LIB1/QRY1) OUTPUT(*OUTFILE) OUTFILE(LIB1/OUT1) SETVAR(FROMD &X))

"
The prompt I receive: "Type a value for variable "X and press Enter".
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 8  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.
  • TheRealRaven
    We need to see the debug value of &X. Also, we should see the *QMQRY source, particularly the exact usage of the FROMD substitution variable. And if FROMD is used as a comparison value against a table column, we need to see the column's database definition.

    Each of those elements will affect how the value must be passed.
    33,670 pointsBadges:
    report
  • felixb

    FROMD is compared to table column of packed decimal 7.

    I changed my cl:

    "

    PGM PARAM(&X)

    DCL VAR(&X) TYPE(*CHAR) LEN(7)

    STRQMQR QMQR(LIB1/QRY1) OUTPUT(*OUTFILE) OUTFILE(LIB1/OUT1) SETVAR(FROMD &X))

    "

    i still receive the error message.

    95 pointsBadges:
    report
  • TheRealRaven
    And we still need to see the query. It could also help to see any message IDs from any error. It could also help to see the debug value of &X.

    We can't know how to fix what we can't see. You need to show us what has the problem.
    33,670 pointsBadges:
    report
  • ToddN2000
    Was this query set up to run interactively and prompt a user for input and you are now try to bypass the prompt and pass a value?
    129,715 pointsBadges:
    report
  • felixb
    How can I set a query to run interactive or batch?
    It's just a QMQRY that created with CRTQMQRY.
    95 pointsBadges:
    report
  • felixb

    I found my mistake

    I changed the strqmqry to

    STRQMQR QMQR(LIB1/QRY1) OUTPUT(*OUTFILE) OUTFILE(LIB1/OUT1) SETVAR('FROMD' &X))

    95 pointsBadges:
    report
  • ToddN2000
    What version of the OS are you running? I cannot see the command STRQMQR. I do see the others like STRQMQRY, STRWMPRC, CRTQMQRY. Maybe it an authority issue for me.
    129,715 pointsBadges:
    report
  • TheRealRaven
    If your command already had FROMD typed as upper-case, then adding single-quotes to it and leaving it upper-case wouldn't have made any difference. Something else was where the problem was.
    33,670 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.

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

Following

Share this item with your network: