I have instances where a simple START with where constraint is failing with 9D156 complaining there is an error near "AND"
The code is pasted below, but essentially we setup a where clause before executing the start
INTEGLOG_STATUS = 'C' AND INTEGLOG_SYSTEM = 'EDMS'
We are running in a single thread so would not expect to need to LOCK THREAD and UNLOCK THREAD
either side of setting the where clause and doing the start. Would using the LOACK THREAD help prevent 9D156?
...here is actual code
INITIALIZE INTEGLOG-REC.
MOVE 0 TO WS-COUNT-1
MOVE "C" TO INTEGLOG-STATUS.
MOVE "EDMS" TO INTEGLOG-SYSTEM.
* the following START has on 2 different occasions failed with 9D156
PERFORM START-INTEGLOG-STATUS-SYSTEM-KEY
IF WS-STATUS NOT = "00"
EXIT PARAGRAPH
END-IF.
*------------------------------------------
START-INTEGLOG-STATUS-SYSTEM-KEY.
*------------------------------------------
PERFORM SETUP-WHERE-CL-4-STATUS-SYSTEM-KEY.
START INTEGRATION-LOG KEY NOT < INTEGLOG-STATUS-SYSTEM-KEY
INVALID KEY
MOVE "92" TO WS-STATUS.
MOVE LOW-VALUES TO A4GL_WHERE_CONSTRAINT.
*------------------------------------------
SETUP-WHERE-CL-4-STATUS-SYSTEM-KEY SECTION.
*------------------------------------------
* this sets up the where clause
IF INTEGLOG-STATUS = SPACE OR LOW-VALUES OR HIGH-VALUES OR ZERO
MOVE LOW-VALUES TO A4GL_WHERE_CONSTRAINT
ELSE
MOVE SPACE TO A4GL_WHERE_CONSTRAINT
MOVE 1 TO WS-4GL-STR-PTR
STRING
"INTEGLOG_STATUS = '"
INTEGLOG-STATUS
"'"
DELIMITED BY SIZE
INTO A4GL_WHERE_CONSTRAINT
WITH POINTER WS-4GL-STR-PTR
END-STRING
IF INTEGLOG-SYSTEM = SPACE OR LOW-VALUES OR HIGH-VALUES OR ZERO
CONTINUE
ELSE
STRING
" AND "
"INTEGLOG_SYSTEM = '"
INTEGLOG-SYSTEM
"'"
DELIMITED BY SIZE
INTO A4GL_WHERE_CONSTRAINT
WITH POINTER WS-4GL-STR-PTR
END-STRING
END-IF
INSPECT A4GL_WHERE_CONSTRAINT REPLACING TRAILING SPACES BY
LOW-VALUES
END-IF.