Share this page

# lr_db_getValue

Retrieves a value from a dataset.

    int lr_db_getValue( "StepName=<step_name>", "DatasetName=<dataset_name>", "Column=<column>", "Row=<row>", "OutParam=<output_parm>", LAST );

Alphabetical Listing - C Language Utility Functions

## Arguments

Name | Comments
--- | ---
StepName | The name of the step, as it appears in the test tree. Any text can be used.
DatasetName | Logical name for the dataset specified in lr_db_executeSQLStatement.
Column | The name of the column in the dataset from which to retrieve the value.
Row | Sets the dataset cursor to the specified row before fetching data. One of: The row number (1-based) `current` - does not move the cursor `next` - sets the cursor to the next row
OutParam | The name of the parameter that will contain the value.
LAST | This delimiter marks the end of the argument list.

The lr_db_getValue function retrieves a value from the dataset created by an lr_db_executeSQLStatement.

This function is supported only under the Windows operating system.

When this function reaches the last row of the dataset, the row is undefined. If `Row=next` is specified the next time lr_db_getValue is called, the script continues to the first record without issuing any errors.

This function does not support the print or output of binary data. Binary values retrieved from the dataset appear as `<binary_data>`.

## Return Values

This function returns LR_PASS on success, LR_FAIL on failure, and -1 when either the dataset cursor is at the last record of the dataset or the first time the function is called.

## Parameterization

All string arguments (char type) can be parameterized using standard parameterization.

## Example

In the following example, lr_db_getValue retrieves the first name of three rows in the dataset created by lr_db_executeSQLStatement. The first name is saved in the parameter MyOutputParam.

    int i=1;
    lr_db_executeSQLStatement("StepName=PerformQuery", "ConnectionName=db1",
        "SQLStatement=SELECT dbo.Customer.CustID, dbo.Customer.FirstName, dbo.Customer.LastName FROM dbo.Customer",
        "DatasetName=MyDataset", LAST );

    while (i<4) {
        lr_db_getvalue("StepName=GetValue",
          "DatasetName=MyDataset",
            "Column=FirstName",
             "Row=next",
            "OutParam=MyOutputParam",
            LAST );
        lr_output_message("The value is: %s", lr_eval_string("{MyOutputParam}") );
        i=i+1;
        }

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: