This how-to article is intended for iPaaS flow builders and administrators and covers how to set up SQL connectors for use in iPaaS. The user must have the "Connector Definitions (Configuration/Connectors)" and "Connector Credentials (Configuration/Connectors)" security permission in iPaaS.
Overview
Use these instructions to set up one of the three SQL connectors available in iPaaS: Microsoft SQL Server, MySQL, and Oracle. SQL connectors require a valid connection string and credentials.
Configuring SQL Connectors
Learn how to create a SQL connector definition and credential in our knowledge base articles:
Defining the Connection String
The SQL connection string specifies which server and database to connect to. You will need to enter the connection string later, when you configure the SQL connector in iPaaS.
The format of the connection string changes based on the type of SQL database you are connecting to.
Oracle
For Oracle databases, there are two methods to connect:
- Service name - refers to one of many databases and is used for load balancing
- SID - refers to a specific database in a specific environment
If you use a service name, you will need to configure a tnsnames.ora file to associate the specific database name(s) and the service name. See the Oracle FAQ for more information on configuring a tnsnames.ora file. If you would like to avoid using a tnsnames.ora file, you can specify the database directly by using its SID, or database name.
The connection string format for Oracle using only a service name is:
Data Source=servername:port/servicename
The connection string format for Oracle using a SID is:
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=servername)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=SID_or_databasename)));
Examples
Here is an example of a connection string for the server name "myserver.teamdynamix.com" using port 8080, with a database name of "tdx-customers".
Oracle with Service Name
Data Source=myserver.teamdynamix.com:8080/tdx-customers
Oracle with SID
Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myserver.teamdynamix.com)(PORT=8080))(CONNECT_DATA=(SERVICE_NAME=tdx-customers)));
MySQL/Microsoft SQL
The connection string format for MySQL or Microsoft SQL is:
server=servername,port;database=databasename
Where servername is the server name or IP address of the server, port is the port number, and databasename is the name of the database to connect to.
Example
Here is an example of a connection string for the server name "myserver.teamdynamix.com" using port 8080, with a database name of "tdx-customers".
server=myserver.teamdynamix.com,8080;database=tdx-customers
Snowflake
The connection string format for Snowflake is:
account=accountname;db=databasename;schema=schemaname;
Where accountname is the name of the account in Snowflake, databasename is the name of the Snowflake database you're connecting to, and schema is the schema to use when making the connection.
Example
Here is an example of a connection string for the server name "myserver.teamdynamix.com" using port 8080, with a database name of "tdx-customers".
account=myaccount.us-east-2.aws;db=myDatabase;schema=tpch_sf1;
Applying the Connection String
Once the connection string is defined, you can apply it at the connector level or the flow level.
- Connector-level string: when the connector is added to the flow, the connection string box already has the default string in it. You can optionally lock the connector so that it cannot be overridden, effectively creating a SQL connector that can only interact with one database.
- Flow-level string: allows flow builders to specify the connection string when they add the connector to a flow.
To specify the connection string at the connector definition level:
- On the top navigation bar, click Configuration > Connector Definitions.
- To the left of the SQL connector, click the Gear Icon.
- In the Connection String box, enter your connection string.
- Click Save Changes.
To specify the connection string at the flow step level:
- On the top navigation bar, click Applications > All Flows > [name of flow].
- Drag a connector step from the Connectors/Notifications section of the flow toolbox to the flow builder and choose the SQL connector.
- In the Connection String box, enter your connection string.
- Click Save Changes.
Testing the SQL Connection
To test that both your credentials are working and your connection string is correct, you can do a basic select statement. If you receive an unauthorized error, you will know that your credentials are incorrect. If you receive another error, you will know that your connection string is incorrect.
To test the SQL connection:
- Navigate to a flow you will use to test the connection
- Drag a connector step from the Connectors/Notifications section of the flow toolbox to the flow builder and choose the SQL connector
- In the Credentials dropdown, choose the credentials to use
- From the Actions dropdown, choose Select
- Type a select statement into the box below:
- For Microsoft SQL/MySQL: type SELECT 1
- For Oracle: type SELECT 1 FROM DUAL
- Click Save Changes
- In the top right corner of the flow design interface, click Test
- To the right of the SQL step, click the play button
Adding Flow Data (Parameters) to SQL Steps
Sometimes, you may want to insert data from elsewhere in the flow into your SQL statement, rather than hand-typing it. You can use a special syntax to create variables or parameters that you can insert into your statements. This is extremely helpful when you want to add a bunch of rows to a table or do other bulk operations.
Dynamic SQL
All iPaaS SQL connectors include actions for each of the common SQL operations (e.g., SELECT, UPDATE, DELETE). These actions have certain limitations; for example, you can't use parameters to specify table names (e.g., SELECT * FROM @tableName).
In the event that the SQL command itself needs to be dynamic, such as passing a table name as a parameter, you can choose the Dynamic action. Any parameters entered will be evaluated in iPaaS before they are passed to the SQL database.
Parameter Syntax
Use a special prefix to indicate parameters in your SQL statement. This prefix varies by connector type.
- MySQL/Microsoft SQL - @parameterName
- E.g.,
SELECT * FROM Users WHERE Type = @UserType
- Oracle/Snowflake - :parameterName
- E.g.,
SELECT * FROM Users WHERE Type = :UserType
Adding Parameters to a SQL Statement
- Add a SQL step to your iPaaS flow.
- In the text area on the step, write your SQL statement, using the parameter syntax as described above.
- In the bottom right corner of the SQL step, click Parse.
- If you see a tab with the word Errors, click the tab to view any errors with your SQL statement. Resolve the errors and click Parse again.
- Click on the Parameters tab. There should be one input bubble for each @parameter or :parameter you entered.
- Type or use the data picker to fill in the data you would like to add in to your SQL statement.
- Click Save Changes.
Executing Stored Procedures
- Add a SQL step to your iPaaS flow.
- Change the Action to Execute Stored Procedure.
- In the SQL Command Text area, simply provide the name of the stored procedure.
- In the bottom right corner of the SQL step, click Parse.
- If you see a tab with the word Errors, click the tab to view any errors with your SQL statement. Resolve the errors and click Parse again.
- Click on the Parameters tab. Any input variables in the stored procedure definition will be displayed.
- Type or use the data picker to fill in the data you would like to add in to your SQL statement.
- Click Save Changes.
Gotchas/Pitfalls
- When using any of the SQL connectors, you must specify column names in order for them to be selectable in the data picker. Using a wildcard, e.g.,
SELECT * will work, but the column names will not be selectable in the data picker.
- When using an Oracle connector, returned data will always have the column headers in ALL-CAPS. When selecting values with the data picker, it may show them in lower case. In this case, you will need to use a "custom" value from the data picker and type the column name in ALL-CAPS.
- If you're trying to dynamically add parameters to a SQL query, you must:
- In the flow, create a property with a list of the parameters
- E.g.,
'parameter1', 'parameter2', 'parameter3'
- You can populate this list dynamically later in the flow (this also works on the list data type)
- Make sure you're using the Dynamic action in the SQL connector
- Under the Parameters tab, use the data picker to select your property
- In your query where you want to pass in a dynamic list of parameters, use the {{}} around the name of the property rather than @
- E.g.,
SELECT * FROM Users WHERE UserID IN ({{PROPERTY_NAME}})