I have DB2 cursor to pull in a list of matching names from a DB2 name table.
My issue is attempting to build a proper COBOL hostvariaable for the LIKE when the search name contains a DB2 wildcard (%_).
For example: FIVE % STORES
When the name does contain one I'll need to add an ESCAPE character so the wildcard is not seen as a wildcard.
The full LIKE syntax would be: LIKE '%FIRST \% STORES' ESCAPE '\'
If I put the above in a SPUFI it works fine but not if I populate a COBOL variable with '%FIRST \% STORES' ESCAPE '\'.
If I STRING single quotes around %FIVE \% STORES so the COBOL hostvar contains:
'%FIRST \% STORES' ESCAPE '\'
The search attempts to locate names that start and end with single quotes
If I do NOT STRING single quotes around %FIVE \% STORES so the COBOL hostvar contains:
%FIRST \% STORES ESCAPE '\'
The search does not work as I believe attempts to locate names with the work ESCAPE in it.
Same with the single quotes around the ESCAPE character, if I do NOT have the quotes
%FIRST \% STORES ESCAPE \
The search does not work.
Any suggestions or insights would be greatly appreciated!