The query select is processed twice – once by CL – processing your string commands
then by the database manager.
When this string is processed by CL
‘APCMPY *EQ ”*CAT XPCMP *CAT”’
APCMPY *EQ ‘ *CAT XPCMP *CAT’
But thats not what the query processor needs
which would look like this – if the value were 00250
APCOMP *EQ “00250”
to get that
OPNQRYF FILE((*LIBL/APH *FIRST *ONLY)) +
QRYSLT(‘APCMPY *EQ ” ‘ *CAT &XPCMP *CAT ‘ ” ‘)
Where ” represents to CL a put a quote here don’t close the string
so this reads
‘APCMPY *EQ ”put a quote here don’t close the string ‘close the string
the string needed to be closed so CL would recognize the *CAT and the field name
*CAT &XPCMP *CAT
which adds the field to the string (note & to indicate a value/field
followed by ‘start string ”put a quote here don’t close the string ‘close the string)
What a monster
I generally have a varable &QSEL
build the value in it and send it do myself during testing, that way I see what
will be sent to the query engine.
Note that Phil has replaced XPCMP with &XPCMP – all variables in a CL are prefixed by a & character.