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:

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:

Create a custom query

To create a custom query, follow these steps:

  1. Follow the detailed instructions to add a connectors task.
  2. When you configure the connector task, in the type of action you want to perform, select Actions.
  3. In the Action list, select Execute custom query, and then click Done.

    image showing execute-custom-query-action image showing execute-custom-query-action

  4. Expand the Task input section, and then do the following:
    1. In the Timeout after field, enter the number of seconds to wait till the query executes.

      Default value: 180 seconds.

    2. In the Maximum number of rows field, enter the maximum number of rows to be returned from the database.

      Default value: 25.

    3. To update the custom query, click Edit Custom Script. The Script editor dialog opens.

      image showing custom-sql-query image showing custom-sql-query

    4. 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 the LastName column:

      SELECT * FROM Employees where LastName=?

    5. 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.

      image showing add-query-param image showing add-query-param

      To add query parameters, do the following:

      1. From the Type list, select the data type of the parameter.
      2. In the Value field, enter the value of the parameter.
      3. To add multiple parameters, click + Add Query Parameter.