Calls to BATSETX()/BATSET() that "exhaust" the batch do not typically close (or clean-up) the batch. The next call will return a BTMT_ERR (428) indicating the batch has no more remaining entries, and the batch is closed. More specifically, this may occur when BAT_GET or BAT_NXT requests are made for: partial key requests (BAT_PKEY); greater or less than key requests (BAT_GKEY, BAT_LKEY); and physical order requests (BAT_PHYS). These "exhausted" conditions can be detected, and we now close the batch and use the new sysiocod signal.
An application calling BATSETX() can now OR BAT_CLSE to the mode parameter. Then when a BAT_PKEY, BAT_RNGE, BAT_GKEY, BAT_LKEY or BAT_PHYS request exhausts all the entries, either in the first call to BATSETX() or in subsequent calls, the batch will be closed immediately, and sysiocod will be set to BTNO_COD to allow the application to know the batch has been closed.
By exhausting a batch we mean returning all the requested information (records, keys, or record positions) which satisfy the batch. Without this modification, an exhausted batch typically requires one additional call (BAT_NXT) to detect the batch is exhausted and cause the batch to be closed, or a call to explicitly request the batch close (BAT_CAN).
See also: