Share this page

# lr_end_transaction_instance

Marks the end of a transaction instance.

    int lr_end_transaction_instance (long parent_handle, int status);

Alphabetical Listing - C Language Utility Functions

## Arguments

Name | Comments
--- | ---
parent_handle | The handle returned by lr_start_transaction_instance at the creation of the instance.
status | The transaction status.

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

You can manually set the status of the transaction instance 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 transaction 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.

To instruct the script to automatically detect the status, specify LR_AUTO. The script returns the detected.

## Return Values

This function returns 0 on success, and a negative number on failure.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## Example

In the following example,lr_start_transaction measures the time of a transaction that performs a withdrawal from a bank server. Once the server API call is completed and returns a value to the status variable, the transaction is complete. However, the test also wants to verify how long an unsuccessful withdrawal transaction will take if the customer is over the withdrawal limit. An instance of the transaction "withdraw" is created for this purpose. lr_end_transaction_instance marks the end of this transaction instance.

Copy code

    long id;
    int status;

    /* Call to server API */
    int amount_overdrawn = get_amount_overdrawn();
    while (amount_overdrawn < LIMIT) {
    /* Notify that a transaction is starting */
        id = lr_start_transaction("withdraw");

    /* Call to server API */
        status = bank_withdraw(500);

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

        amount_overdrawn = get_amount_overdrawn();
    }
    /* The client is unable to withdraw anymore as the overdraft limit has been reached. Try to withdraw anyway to record the server response time */
        id = lr_start_transaction_instance("withdraw", 0);

    /* This call will fail, but we want to time it */
        status = bank_withdraw(500);
        lr_end_transaction_instance(id, LR_PASS);

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