SQL Connector Call Modes
When creating a SQL connector call, you can create your SQL statement in the first tab “SQL”.
Select the Mode parameter:
|simple||Simple SQL Query without variables or dynamic parameters|
|query||Parameterized SQL query|
|execute||Insert or Update Statements without a return|
|transaction||SQL Transactions with Rollback on Error|
|repeatable statement||Repeatable SQL Statements for Insert or Update Queries for Mass Inserts, Updating|
In the connector call overview, you can find the connector Wizard in the top right corner.
With the SQL Wizard, it’s easy to configure new connector calls based on SQL Connectors for MySQL and Oracle.
When opening the Wizard, all tables available for the schema are displayed.
First Step – Select Queries:
In the first step, you can search for the table, and then select under “Actions” whether you want to select all columns (right icon) or only certain ones (left icon).
|If you only want to select certain ones, click on the left icon. A new popup opens in which you can select the desired columns. Then click OK.|
Second Step – Configure connector Calls:
After you have selected the desired tables and, if necessary, their columns, you can edit the connector calls by clicking on “Edit connector Calls”.
When you have edited the calls, click on “Create connectorcalls”.
The ‘Simple Call’ corresponds to an unparameterized SQL call.
The SQL request is defined by a ‘String’ without variable substitution.
In order to be able to process the output of the SQL request, it must be defined in the output parameter of the connector call.
Currently, you can still map the entire JSON result to a single parameter.
This is possible by specifying a ‘/’ as the parameter name and the data type ‘String’ in the output parameters.
The ‘Query Call’ is used to transfer the result from an SQL statement to the Simplifier.
(Usually, SELECT statements have a result)
The SQL request of the ‘Query Call’ is parameterized (in contrary to the ‘Simple Call’).
Definition of the constant value for the request parameter
The input value of the request parameter is represented by a name and a Simplifier data type. In our example, we used the name ‘mail’ and the data type ‘String’.
A parameter definition is initiated and ended with a colon. Between the colons is a pair of values, separated by a colon as well, which represents the name and the type of the parameter.
In a parameterized SQL request:
SELECT * FROM user_data WHERE email LIKE :mail:
If you use more values in an SQL statement you have to use a syntax separated by a comma, e.g. VALUES (:id:,:mail:)..
Dynamic WHERE clause
For executing dynamic-created WHERE Clauses – please read the following lines:
Let’s see how we need to configure our connector Call to make use of this function.
Here you can see that you only need to write your regular SQL statement without the WHERE clause after it in the ‘SQL’ tab of the connector Call.
In the input mapping we need to specify a new parameter called ‘where’ which acts as a placeholder for your WHERE clause that you want to append to the SQL statement.
Here’s how our result looks like if we use different values for the ‘where’ parameter and test the connector Call in the Simplifier UI:
And this is a demonstration of the aforementioned bad word filter if you try to pass reserved words from the list (please see below) to the ‘where’ parameter.
For Security Reasons, we filter out bad commands that will result in a rejection of the call:
- INSERT (INTO)
- UNION (ALL)
Please note that this filter will only trigger if it finds the exact same word in your WHERE clause.
The ‘Execute Call’ is quite similar to the ‘Query Call’. But with the ‘Execute Call’, no result is sent back to the Simplifier.
Typically SQL INSERTs, UPDATEs, or DELETEs could be used in that way.
To execute multiple queries in a single transaction, use the mode ‘Transaction’. It bundles all executed statements as one database transaction.
The transaction mode has a delimiter setting, which is semicolon by default. Each statement is executed in the specified order and returns the result set. MySQL, MS SQL, and SQLite additionally return values for automatic increment.
To execute a SQL statement for each entry in a collection, you can use the repeatable statement mode.
You can simply select the mode “repeatable statement” from the dropdown menu as you are used to with other modes like ‘execute’, ‘query’ etc.
After selecting this mode you can write any SELECT, INSERT or UPDATE statement that you want to have executed for each entry in a collection that is passed to the connector Call by means of a new parameter called ‘parameterCollection’.
You can specify it as an input parameter in your call and then pick the appropriate collection data type for it.
Leave A Comment
You must be logged in to post a comment.