lr_end_sub_transaction
Marks the end of a sub-transaction.
int lr_end_sub_transaction( char *sub_transaction, int status );
| Alphabetical Listing - C Language Utility Functions |
Arguments
| Name | Comments |
|---|---|
| sub_transaction | A string indicating the name of an existing sub-transaction. |
| status | The transaction status. |
The lr_end_sub_transaction function marks the end of a sub-transaction. To mark the beginning of the sub-transaction, use the lr_start_sub_transaction function. You insert these functions immediately before and after the sub-transaction steps.
Multiple sub-transactions can be nested within a parent transaction, but each lr_end_sub_transaction statement must match an lr_start_sub_transaction statement or it will be interpreted as an illegal command.
Return Values
This function returns 0 if it succeeds. It returns -1 if the transaction name is illegal or if there is no prior call to lr_start_transaction with a transaction of the same name.
Parameterization
You cannot use standard parameterization for any arguments in this function.
Example
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);

