Example: lr_end_sub_transaction
In the following example, a sub-transaction called "electrical_purchases," performs purchases of six electrical items. If this sub-transaction is successful, the transaction status is recorded as LR_AUTO. The default value of LR_AUTO is LR_PASS. If the purchase is unsuccessful, the value is set as LR_FAIL.
/* Notify that a transaction is starting */
lr_start_transaction("purchases");
/* Breakdown the transaction into a smaller transaction */
lr_start_sub_transaction("electrical_purchases", "purchases");
status = purchase_electrical_items(6); /* call to Server API */
/* End transaction with operation result - pass or fail */
if (status == 0) lr_end_sub_transaction("electrical_purchases", LR_AUTO); else lr_end_sub_transaction("electrical_purchases", LR_FAIL);