Utility Functions and C Language Reference > Utility Functions: C Language (lr_) > Alphabetical Listing > lr_db_executeSQLStatement

lr_db_executeSQLStatement

Submits an SQL statement to a database.

C Language

int  lr_db_executeSQLStatement("StepName=<step_name>", "ConnectionName=<connection_name>", "SQLStatement=<statement>", ["DatasetName=<dataset_name>",] LAST );
Example: lr_db_executeSQLStatement Database Functions

Arguments

Name Comments
StepName The name of the step, as it appears in the test tree. Any text can be used.
ConnectionName The logical name for the connection specified in lr_db_connect.
SQLStatement The SQL statement, such as SELECT, INSERT, DELETE, and UPDATE. The syntax is database-dependent. SQLStatement can be parameterized.
DatasetName Logical name for the resulting dataset from the SQL query, by which you can refer to the dataset in subsequent steps. For use only when SQLStatement is a SELECT statement.
LAST This delimiter marks the end of the argument list.

The lr_db_executeSQLStatement submits an SQL statement to a database.

This function is supported only under the Windows operating system.

When SQLStatement is a SELECT statement, DatasetName points to the resulting dataset. In this context, the term dataset is used to describe tables of data (formatted as rows and columns). The data in the dataset can be manipulated by subsequent steps in the script.

When SQLStatement is either DELETE, INSERT, or UPDATE, a warning is issued.

After calling this function, the row is undefined. In this case, make sure to set Row to next or 1 if calling lr_db_getValue after this function.

Return Values

On failure, this function returns LR_FAIL. On success, this function returns the number of records in the dataset. The number of records does not include header rows produced in the output.

Parameterization

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