By default, BAT_UPD extracts the unique key from the record image, reads the record and then uses the record image provided in the input buffer to perform an Update operation. If the extracted key does not exist, a record ADD operation is performed. A mode called BAT_UPD_KEY is provided in which the old key can be specified for situations in which a rewrite might change the unique key used to locate the record.
Overview of Operations Performed
For each record in the input buffer, the batch update operation will do the following:
Notice that a missing key implies that a new record will be added.
A unique key is required on the file. If the index allows duplicates, the operation will return an error, so it is important to specify which unique index to use.
The function will return the number of records that were added and the number of records that were updated.
Update Modes
This operation provides two update modes:
In both cases, variable-length data files have the 4-byte length of the data record as the first field of each entry.
In the default BAT_UPD mode, entries are formatted as shown below:
When BAT_UPD_KEY mode is used, entries are formatted as:
The BAT_UPD_KEY mode should be used when a rewrite might change the unique key used to locate the record. The old key permits the record to be located and read before the rewrite operation.
Batch Updates and BAT_RET_BLK Format
Beginning with c-treeACE V11, batch update now recognizes BAT_RET_BLK record format. When using batch update to add variable-length records that were read using a batch physical read with the BAT_RET_BLK option, the batch update failed with error SDAT_ERR. Batch update logic has been modified to recognize the BAT_RET_BLK record format.
Additional Modes
Additional modes can be used with BAT_UPD and BAT_UPD_KEY to provide record locking. See Batch Update operations: BAT_UPD and BAT_UPD_KEY.