Execute custom query
This page shows you how to execute a custom SQL query. To execute a custom query, you must be familiar with the following concepts:
- Creating integrations using Application Integration
- Connector task
- Integration Connectors
- SQL queries
The Execute custom query is exposed to you as an action in the
Connector task. An action is a first
class function that is made available to the integration through the connector interface. Actions
let you make changes to an entity or entities, and vary from connector to connector. However, it is possible
that a connector doesn't support any action, in which case the Actions
list will be empty.
The following connectors support custom query:
- BigQuery
- Cloud SQL - MySQL
- Cloud SQL - PostgreSQL
- Cloud SQL - SQL Server
- Couchbase
- Elasticsearch
- MySQL
- Oracle DB
- PostgreSQL
- Salesforce
- SQL Server
- Snowflake
- Spanner
- Terdata
Create a custom query
To create a custom query, follow these steps:
- Follow the detailed instructions to add a connectors task.
- When you configure the connector task, in the type of action you want to perform, select Actions.
- In the Action list, select Execute custom query, and then click Done.
- Expand the Task input section, and then do the following:
- In the Timeout after field, enter the number of seconds to wait till the query executes.
Default value:
180
seconds. - In the Maximum number of rows field, enter the maximum number of rows to be returned from the database.
Default value:
25
. - To update the custom query, click Edit Custom Script. The Script editor dialog opens.
- In the Script editor dialog, enter the SQL query and click Save.
You can use a question mark (?) in a SQL statement to represent a single parameter that must be specified in the query parameters list. For example, the following SQL query selects all rows from the
Employees
table that matches the values specified for theLastName
column:SELECT * FROM Employees where LastName=?
- If you've used question marks in your SQL query, you must add the parameter by clicking + Add Parameter Name for each question mark. While executing the integration, these parameters replace the question marks (?) in the SQL query sequentially. For example, if you have added three question marks (?), then you must add three parameters in order of sequence.
To add query parameters, do the following:
- From the Type list, select the data type of the parameter.
- In the Value field, enter the value of the parameter.
- To add multiple parameters, click + Add Query Parameter.
- In the Timeout after field, enter the number of seconds to wait till the query executes.