Example: lr.start_sub_transaction and lr.end_sub_transaction

Example 1

In the following example,lr.start_sub_transaction and lr.end_sub_transaction create a transaction that performs purchases of six electrical items. The parent transaction is purchases and the sub-transaction is electrical_purchases.


/* Breakdown the transaction into a smaller transaction */ 
lr.start_sub_transaction("electrical_purchases", "purchases");

/* call to Server API */  
int status = purchase_electrical_items(6); 

/* End transaction with operation result - pass or fail */ 
if (status == 0) 
    lr.end_sub_transaction("electrical_purchases", lr.PASS); 
    lr.end_sub_transaction("electrical_purchases", lr.FAIL); 
lr.end_transaction("purchases", lr.AUTO);