Query Database

Use this step to extract data from the selected database. To change records in your database, use the Execute SQL step. To store data in a database, use the Store In Database step.

This step opens an application in the Recorder View with one extracted row. The row data is available in the table and tree views. This step works as a loop step that iterates over the rows returned by the query. Each iteration updates the contents of the views with data extracted for the next row. After all rows are iterated (or the Robot exits the loop with an exception or a Break step), the application automatically closes. It also closes if the Robot stops executing.

The Robot may use an iteration variable and Continue and Break steps to control the loop execution as the other loop steps.

Use Extract steps to extract the returned data from the application tree as usual.

The Query Database step belongs to the Database and Loop categories.

Properties

Configure the Query Database step using the following properties.

Database Mapping

Select a database mapping from the databases specified in the Call Robot step.

SQL Statement

Type a SQL statement to execute on the selected database, such as select * from departments;.

The robot does not evaluate the statement you type. Check your SQL statements beforehand or you can check the validity of the statement just by executing the step.

Application name

Set the name of the application the step opens. The name specified in this required parameter is used in the application's name and title attributes.

Assign different application names to applications in a robot to avoid errors.

Iteration Variable (optional)

Specify a variable to store iteration data.

Timeout

If selected, you can specify timeout for submitting SQL statements in seconds. The value must be greater than zero. The timeout is enforced through DBMS and if it is reached, the DeviceIssue exception is thrown with an error message specific to the database.

Various DBMS types and JDBC drivers may handle timeouts differently. For example, not every system allows a timeout to trip in the middle of certain statements.

Statement Type

For more information on statement types, see Execute SQL.

Component actions

The columns of long binary (BLOB) and long text (CLOB) database types are not read into the application tree. Instead, you should use the Read Long Binary Value or Read Long Text Value component actions, respectively, to read the values from columns of these types. These actions let you specify a variable to read the long data to and a flag indicating whether the robot should throw an exception if the NULL data is read. This flag is off by default indicating that the NULL data treated as empty data.