Passing library in a QMQRY

Tags:
AS/400
QMQRY
I have a simple QMQRY with a select statement "SELECT * FROM SFMNC". But the file SFMNC are in a number of libraries. I want to pass the name of the library to the QMQRY. Is this possible?
1

Answer Wiki

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

When running from a CL program, try doing an OVRDBF before QMQRY SELECT statement point to the correct library.

Discuss This Question: 4  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.
  • Kaustav00001
    Thanks for the feedback.. The problem is sometimes I need to run the query on the SFMNC file on 3 or four libraries one by one depending on  the data. Thats why i need to specify the library.
     
    65 pointsBadges:
    report
  • Splat
    DLTOVR is your friend in that circumstance.
    12,925 pointsBadges:
    report
  • TheRealRaven
    SELECT * FROM &lib/SFMNC

    By using a substitution variable, you can pass a library name in through the STRQMQRY SETVAR() parameter. IN the above example, it might be like SETVAR(('lib' QGPL)).

    Note that the substitution variable name is case-sensitive! The name value therefore needs to be surrounded by apostrophes in the above example in the SETVAR() parm.
    37,065 pointsBadges:
    report
  • Kaustav00001
    Thanks a lot..Thats working

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