One additional remarks:

Having variables defined as &a or &A makes a difference:

using &a will always prompt for user input, even in queries running in batch 
(job is in MSGW).
using &A will allow you to pass parameters in batch programmes or interactively 
without prompting; of course the values have to be passed to the query in their 
proper format (character parms within double single quotes), otherwise the 
"prompt" will display.

Hence, always define the variables in upper case.

Regards,
Carel Teijgeler

*********** REPLY SEPARATOR  ***********

On 21-9-05 at 21:49 Vernon Hamberg wrote:

>I could have used lower case for the variable names because the 
>iSeries automatically uppercases these things if there are no 
>apostrophes. You could, I suppose, have separate UC & LC variables, 
>like &a and &A, but I can think of only one good use for that.
>
>The point of all this is, the statement is a string, and whatever you 
>put in the setvar element replaces the variable in the statement. The 
>setvar value must be a string, even numbers. Quoted strings are a bit 
>of a problem, but someone came up with a brilliant way to handle 
>them. E.g., with this statement in QMQRY TEST1
>
>select * from myfile where charfield = &STRING and numfield = &NUMBER
>
>strqmqry test1 setvar((string 'mystring') (number '35'))
>
>results in
>
>select * from myfile where charfield = mystring and numfield = 35
>
>and will fail because it thinks that mystring is a column name. One 
>solution is to put the quotes into the setvar value
>
>strqmqry test1 setvar((string '''mystring''') (number '35'))
>
>which is ugly but we have got used to it over the years. But the 
>elegant way is to have a &Q substitution variable
>
>select * from myfile where charfield = &Q&STRING&Q and numfield = &NUMBER
>
>and use the following
>
>STRQMQRY TEST1 SETVAR((STRING 'mystring') (NUMBER '35') (Q ''''))
>
>which becomes
>
>select * from myfile where charfield = 'mystring' and numfield = 35
>
>which is the desired result, because &Q is replaced by the single 
>apostrophe defined in the SETVAR parameter - remember, to get a 
>single apostrophe you double up apostrophes within the opening and 
>closing apostrophes that indicate a character literal.
>
>Sub variable names are everything from right after the ampersand up 
>to but not including another ampersand or a space.
>
>I recommend the Query Management Programming Guide, it's at 
>www.iseries.ibm.com/infocenter (pick any continent and release) in 
>the Database section at V5R3, in the Printed versions section or some 
>such. Has good treatment of the quoted strings stuff. And a lot more 
>you don't even want to know, esp. about forms. You are much better 
>off using Query Manager (STRQM) to do forms.
>
>There is also the Query Manager guide or tutorial or whatever - nice intro.
>
>BTW, once you put the sub vars into a statement, you can not prompt 
>the statement in Query Manager - just the way it is.
>
>And comments are done with double-dashes.
>
>HTH
>Have fun
>
>Vern
>
>At 07:29 PM 9/21/2005, you wrote:
>
>>especially when the QM query is run from a CL or REXX EXEC?    I seem to
>>remember putting something like ? marks in the query syntax/SQL but
>>can't remember.
>>
>>OR better yet, what is the syntax for passing parms to QM so it can be
>>invoked by a CL or REXX PGM?   The latter would be used if I built a
>>front end screen and needed to pass the variables from the screen to the
>>command.
>>
>>Thanks in advance,
>>
>>Dave
>>--
>>This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
>list
>>To post a message email: MIDRANGE-L@xxxxxxxxxxxx
>>To subscribe, unsubscribe, or change list options,
>>visit: http://lists.midrange.com/mailman/listinfo/midrange-l
>>or email: MIDRANGE-L-request@xxxxxxxxxxxx
>>Before posting, please take a moment to review the archives
>>at http://archive.midrange.com/midrange-l.
>
>-- 
>This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
>To post a message email: MIDRANGE-L@xxxxxxxxxxxx
>To subscribe, unsubscribe, or change list options,
>visit: http://lists.midrange.com/mailman/listinfo/midrange-l
>or email: MIDRANGE-L-request@xxxxxxxxxxxx
>Before posting, please take a moment to review the archives
>at http://archive.midrange.com/midrange-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.