Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possbile to pass Select condition to query in STRQMQRY?

Status
Not open for further replies.

Ju5

Programmer
May 25, 2007
85
PH
I am trying to pass a date range to a query and run the query using STRQMQRY. Is this possible?

The query runs automatically every month so it needs the date range for its select criteria changed automatically before the query is run.

&DATSEL = 'date'

CHGVAR VAR(&FROM) VALUE(&YYYY *CAT &MM *CAT '01')
CHGVAR VAR(&TO) VALUE(&YYYY *CAT &MM *CAT '99')

CHGVAR VAR(&QRYSLT) VALUE(&DATSEL *CAT ' *GE ' *CAT +
&QOTE *CAT &FROM *TCAT &QOTE *CAT +
&ND *CAT &DATSEL *CAT ' *LE ' *CAT +
&QOTE *CAT &TO *TCAT &QOTE)

STRQMQRY QMQRY(&QUERY) OUTPUT(*PRINT) QMFORM(&QUERY) +
ALWQRYDFN(*YES) SETVAR((QRYSELECT +
&QRYSLT) (COND1 &SEL1) +
(COND2 &SEL2) (COND3 +
&SEL3) (COND4 &SEL4) (COND5 &SEL5))

The program has just finished it's monthly run but the report I received from the query is the result of the saved select statement, it didn't use the calculated date range from the program. Did I do something wrong?

The query was created using STRQRY.
 
The query was created using STRQRY because of some calulations and formatting required by the report.
 
Will removing the library allow the query to search all the libraries or will it make it fail?

How can I edit the SQL for a query created using QMQRY? DO I just convert it to SQL? I need to change a literal to a variable.
 
Looks like DB2 Query Manager works when trying to edit SQL.

flapeyre,
it helped a lot. thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top