Fran
I think, with Elvis' second reply, that the problem is not with
INPARCEL - it's with the numbers. which should NOT have single quotes
around them in the final string. Your interactive use of STRQMQRY -
you were just lucky - the numbers are being cast to character values.
Remember, the SETVAR values are ALL alpha values. They are being
strung into a SELECT statement that is a character string. In your
program you are forcing the numbers to be alpha values, and those to
not match the numeric fields in your physical file. What version of
the OS are you on? V5R4 does some automagic casting of data types
that can get confusing.
Let me offer a way to do this that is really slick - I think Tom
Liotta suggested it some time ago. Let's assume your SELECT statement
in the QMQRY is like this
SELECT * FROM MYLIB/MYFILE WHERE NEGFLD = &INNEG and POSFLD = &INPOS
and PARCEL = &INPARCEL
Only the field PARCEL is an alpha field. To avoid dealing with all
this funky quotes stuff, write it like this--
SELECT * FROM MYLIB/MYFILE WHERE NEGFLD = &INNEG and POSFLD = &INPOS
and PARCEL = &QT&INPARCEL&QT
Then make STRQMQRY like this
STRQMQRY QMQRY(TRSFDD/TX_OVRPQ1X) ALWQRYDFN(*YES) SETVAR((INNEG
'24.90') (INPOS '24.90') (INPARCEL 'B018001304') (QT ''''))
Remember, the CHARACTER values in the SETVAR elements will be
inserted into the CHARACTER string that is the SELECT statement. The
resulting SELECT statement will be
SELECT * FROM MYLIB/MYFILE WHERE NEGFLD = 24.90 and POSFLD = 24.90
and PARCEL = 'B018001304'
exactly as you want it. With this technique, just make all your
variables and values that you use in the SETVAR to be *CHAR with no
extra apostrophes. And you will NOT need to use that &APOST variable
except, perhaps, as the value for QT.
In case you wondered, you CAN have lower and mixed case substitution
variables. You could have &inNeg as the value in the QMQRY - just use
quotes around it in the SETVAR, like this--
SETVAR(('inNeg' '24.90'))
If you happen to use lowercase for the variable name without quotes,
it will be UPPER'd, just as CL does with all other single-word
character values in commands.
But you can have both &A and &a - they are not the same in a QMQRY -
not sure about in a merge type of QRYDFN, however.
HTH
Vern
At 04:36 PM 12/20/2007, you wrote:
I've looked through the archives and don't see anything that matches
exactly my problem. I can get numeric data passed to the query -
but, for some dumb reason, the character field not happening.
Calling the query manager interactively works:
STRQMQRY QMQRY(TRSFDD/TX_OVRPQ1X) ALWQRYDFN(*YES) SETVAR((INNEG
24.90) (INPOS 24.90) (INPARCEL '''B018001304'''))
But am having difficulty with the parms in a CL
DCL VAR(&PARCEL) TYPE(*CHAR) LEN(10)
DCL VAR(&INPARCEL) TYPE(*CHAR) LEN(12)
DCL VAR(&APOST) TYPE(*CHAR) LEN(1) VALUE('''')
CHGVAR VAR(&INNeg) VALUE(&APOST *CAT &NegAmt +
*CAT &APOST)
CHGVAR VAR(&INPos ) VALUE(&APOST *CAT &PosAmt *CAT +
&APOST)
CHGVAR VAR(&INParcel ) VALUE(&APOST *CAT &Parcel *CAT +
&APOST)
This does not work because I need more quotes around the character
field (parcel).
I've tried several different ways to get it to work to no avail.
Tried these among others: /* CHGVAR VAR(&INPARCEL)
VALUE(&PARCEL) */ including adding a zillion quotes.
Thanks for your help.
Fran Denoncourt
Sr. Programmer/Analyst
Pinal County Treasurer's Office
Florence, AZ 85232
(520) 866-6404
As an Amazon Associate we earn from qualifying purchases.