Updated Batch Arsenal

Updated Batch Arsenal

Posted By: David Faust

c‑treeACE batch operations greatly improve performance by reducing the number of round-trips to the server when processing a group of related records. New additions to c‑treeACE batch operations added in V10.3 extend this valuable capability.

Previously, batch operations provided capabilities to bulk retrieve or delete records matching a partial key. A new powerful batch update mode joins these bulk record operations in the batch function. We have added capability to update a collection of records, each identified by its unique key.

New Options

By default, the new BAT_UPD option 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 Batch Update Operations

For each record in the input buffer, the batch update operation performs the following:

Either begin a transaction or establish a save point if the user already has an active transaction.

Build target key from the unique key.

Read the record with the requested lock:
– If the record exists, update it.
– If the record does not exist, add it.

In case of success or failure: Commit or abort the transaction or clear or restore the save point.

Release record locks if requested.

Note that a missing key implies a new record will be added.

A unique key is required on the file. If the chosen index allows duplicates, the operation will return an error, so it is important to specify which unique index to use.

The batch function returns the number of added records and the number of updated records.

Update Modes

The Update operation provides two update modes:

BAT_UPD (default) – The batch update call sends a series of record images and the filno parameter corresponds to a unique key index.

BAT_UPD_KEY – Record images are preceded by the key value uniquely identifying the record to be rewritten or added.

With both modes, variable-length data files include a 4-byte data record length as the first field of each entry.

Archives

Resources

SIGN UP FOR OUR NEWSLETTER

FairCom needs the contact information you provide to us to contact you about our products and services.
You may unsubscribe from these communications at anytime. For information on how to unsubscribe,
as well as our privacy practices and commitment to protecting your privacy, check out our Privacy Policy.