Share this page

# lr_end_transaction

Marks the end of a transaction.

    int lr_end_transaction( char *transaction_name, int status) ;

Alphabetical Listing - C Language Utility Functions

## Arguments

Name | Comments
--- | ---
transaction_name | A string indicating the name of an existing transaction.
status | The Transaction Status

The lr_end_transaction function marks the end of a transaction and records the amount of time it took to perform the transaction. To indicate a transaction to be analyzed, place the lr_start_transaction function before the transaction, and the lr_end_transaction function after the transaction.

You can manually set the status of the transaction or you can allow the script to detect it automatically. To manually set the status, you perform a manual check within the code of your script (see example) evaluating the return code of a function. For the "succeed" return code, set the status to LR_PASS. For a "fail" return code, set the status to LR_FAIL. For an "aborted" return code, set the status to LR_STOP.

If status is LR_AUTO, then the value of status is automatically assigned. By default, this value is LR_PASS signifying a successful transaction. However, if prior to lr_end_transaction, you change the default value using lr_set_transaction_status, lr_set_transaction_status_by_name, lr_set_transaction_instance_status, or lr_fail_trans_with_error, then this is the value which is passed as status in lr_end_transaction.

If you make a series of calls to functions that modify the LR_AUTO status, then it is the last call before lr_end_transaction which effectively changes the status.

## 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, the lr_end_transaction function measures the transaction time for performing a deposit to a bank server. Once the server API call is completed and returns a value to the rc variable, the transaction is complete. The user manually sets the transaction status, based on the success or failure of the deposit.

     /* Notify that a transaction is starting */
    lr_start_transaction("deposit");

     /* Server API call */
    rc = bank_deposit (50);

     /* End transaction with operation result - pass or fail */
    if (rc == 0)
        lr_end_transaction("deposit", LR_PASS);
    else
        lr_end_transaction("deposit", LR_FAIL);

Tips to improve your search results... VuGen Function Reference Version 26.1 Function Reference 26.1 All View Local Help Center View Online Help Center Version: