Title: Using The Database Index Filter Routines
Description: Getting LIKE to work
regniba - February 5, 2008 06:41 PM (GMT)
Has anyone used the Database Index Filter Routines
using the LIKE in the filter string and gotten it to work?
I've used it other ways but not using LIKE and when it performs the filter create
it bombs and says that the percent sign being used is an illegal character.
This is the character that is in all the examples.
Any guidance would be appreciated. :blink:
Thanks,
Barb
Milo - February 5, 2008 09:25 PM (GMT)
SQL appears to use "%" as a global wildcard & uses underline "_" as a single-character wildcard.
Where is the error message coming back from? More importantly, can you see the actual SQL which is being sent to the database??
regniba - February 6, 2008 03:50 PM (GMT)
I get the error at time of execution of the 890-CREATE-FILTER see below:
890-CREATE-FILTER: error at FILTER-STRING(30)
illegal character '%'.
FILTER-STRING context:
[(IMC-DESCRIPTION LIKE 'ABBOTT%')
^
ParseFilterString() failed.
Yet, the documentation for this API has it in its examples of how to use the LIKE
(In the display of this posting the carrot is really under the % sign)
Tim_Autry - March 5, 2008 06:12 PM (GMT)
Did you ever get this figured out?
The only way I got it to work, was to set some working storage fields equal to the "like" values I wanted to filter by. Then once I built the filter, move the WS field into the appropriate FILTER type.
Example:
Working Storage:
03 WS-FILTER-DEPT1 PIC X(02) VALUE "1%".
03 WS-FILTER-DEPT2 PIC X(02) VALUE "7%".
03 WS-FILTER-STAT PIC X(02) VALUE "T_".
Procedure Division:
STRING "((EMP-DEPARTMENT LIKE ?) OR"
DELIMITED BY SIZE INTO FILTER-STRING
POINTER ZH630-FILTER-LENGTH.
STRING " (EMP-DEPARTMENT LIKE ?))"
DELIMITED BY SIZE INTO FILTER-STRING
POINTER ZH630-FILTER-LENGTH.
STRING " AND (EMP-EMP-STATUS NOT LIKE ?)"
DELIMITED BY SIZE INTO FILTER-STRING
POINTER ZH630-FILTER-LENGTH.
PERFORM 890-CREATE-FILTER.
MOVE WS-FILTER-DEPT1 TO ALPHANUM-FILTER-VALUE.
PERFORM 890-SET-ALPHANUM-FILTER-VALUE.
MOVE WS-FILTER-DEPT2 TO ALPHANUM-FILTER-VALUE.
PERFORM 890-SET-ALPHANUM-FILTER-VALUE.
MOVE WS-FILTER-STAT TO ALPHANUM-FILTER-VALUE.
PERFORM 890-SET-ALPHANUM-FILTER-VALUE.
MOVE PRM-COMPANY TO DB-COMPANY.
MOVE EMPSET3-COMPANY TO WS-DB-BEG-RNG.
PERFORM 850-FILTER-BEGRNG-EMPSET3.
regniba - March 5, 2008 06:16 PM (GMT)
I did not get it figured out because the need kind of went away. You know how things go. Thanks for this though. The examples do not indicate that you have to do this....quite maddening!
skonduru - March 7, 2008 09:45 AM (GMT)
Check for an example usage in MA67 in 8.10 or 9.0 versions.