Execute ODBC Command
Runs an Open DataBase Connectivity (ODBC) command that can return null, a scalar value or a data table.
Command availability: IBM RPA SaaS and IBM RPA on premises
Description
To connect to a database, use the following commands:
- Connect to MySQL
- Connect to Oracle
- Connect to SQL Server
- Connect to SQLite
- Connect to PostgreSQL
- Connect to ODBC
To run an SQL statement, use the Run SQL Command.
Script syntax
IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.
executeOdbc --connection(String) --command(String) --results(ExecuteSqlResults) (Boolean)=isnull (String)=value (DataTable)=table (Numeric)=rows (Numeric)=columns
Input parameter
The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.
Designer mode label | Script mode name | Required | Accepted variable types | Description |
---|---|---|---|---|
Connection string | connection |
Required |
Text |
Connection string to access the database. |
ODBC Command | command |
Required |
Text |
The ODBC command. |
Type of result | results |
Required |
ExecuteSqlResults |
The type of result to return. See the results parameter options. |
results
parameter options
The following table displays the options available for the results
input parameter. The table shows the options available when working in Script mode and the equivalent label in the Designer mode.
Designer mode label | Script mode name | Description |
---|---|---|
None | None |
Return value in the Null output parameter. |
Scalar | Scalar |
Return value in the Result output parameter. |
Data Table | DataTable |
Return value in the Data Table, Rows, and Columns output parameters. |
Output parameter
Designer mode label | Script mode name | Accepted variable types | Description |
---|---|---|---|
Null | isnull |
Boolean |
Returns True if it does not return a value, or False otherwise. |
Result | value |
Text |
Returns the result. |
Data Table | table |
Data Table |
Returns the data in a data table. |
Rows | rows |
Number |
Returns the number of rows of the data table. |
Columns | columns |
Number |
Returns the number of columns of the data table. |
Example
Runs an ODBC command with the current date as a scalar value.
defVar --name commandResult --type String
// Executes an ODBC command to get the current date as a scalar data.
executeOdbc --connection "Driver={Microsoft Excel Driver (*.xls)};DBQ=c:\\bin\\book1.xls" --command "CURRENT_DATE( ) (ODBC 3.0) " --results "Scalar" commandResult=value
logMessage --message "Command Result: ${commandResult}" --type "Info"