Passing parms to Query400

120 pts.
Tags:
AS/400
AS/400 Query
IBM iSeries
Has anyone ever come across a method of passing a parm into a query run - such as a date?

Answer Wiki

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

Go into your query and select ‘Select records’

If the date field in your file is named MyFileDate then use a selection of ‘MyFileDate EQ :input’ (notice the colon before my made up name of input)

On the Specify Dependent Value Qualifiers panel specify ‘1’ (Query) and type in the name of your query

Save your query

Run your query using the STRQMQRY command. If your query is name MyQuery and the date you want to pass for record selection is ‘022608’ use:

STRQMQRY QMQRY(MYQUERY) ALWQRYDFN(*YES) SETVAR((INPUT '022608'))

Bruce Vining

Discuss This Question: 7  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.
  • jldunn
    How would the command be structured if the command is being called from a CL program using a variable in the setvar?
    55 pointsBadges:
    report
  • DoneThat
    Bruce: All the years I ran query (before replacing it with SQL), I never knew that existed. OY! Great little piece of info. Gary
    830 pointsBadges:
    report
  • slateken
    Pardon my French, Bruce, but that is some cool sheet! I'm a little embarrassed now thinking back to the times I said, "Can't be done w/ Query/400". Then I'd create a QM Query to do it. Or a HLL app. Or I'd create an input file to contain one record, fill that record w/ the parms dynamically , then have the query link up the "parm record" with the data I need. This is good stuff. So I decided to play a little and came up w/ 2 questions regarding the method... 1.) Testing w/ a NAME field... I get an error on the comma when passing a name in LAST,FIRST format. Do you know of a workaround? 2.) In my testing (and after a reasonable amount of head-scratching and google-ing) I can't seem to get dependent value qualifiers to work with LIKE and NLIKE comparison operators... any advice? Thanks for the great tip.
    230 pointsBadges:
    report
  • DoneThat
    Slateken: You're right - not obvious how to use multiple parms. Enter Bruce's cmd WITH the SETVAR in place then hit F4. Then F10 for Addl parameters. Looks like you can enter as many as you want. And you'll get the syntax after you hit enter. Gary
    830 pointsBadges:
    report
  • DanTheDane
    Slateken: re 1: You must enclose char-values in a set of triple quotes. For example: SETVAR((NAME '''SMITH''') re 2. Propably not supported... I'm as curious as you. DanF
    2,555 pointsBadges:
    report
  • slateken
    DanF and Gary: Thanks for the advice. Trip-quotes worked like a charm, Dan. I'll just stay in a holding pattern on the LIKE / NLIKE issue.
    230 pointsBadges:
    report
  • Ssboy

    I *think* I have mine set up correctly, but I still get PROMPTED for the value. User will not be entering a value - they will be selecting a record to PRINT off a screen. Because they are looking at the record, they aren't going to want to re-enter the key information.

    Help?

    15 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: