Please check the SELECT Action and Trigger.
Use this action to insert, update or delete some data, returned value is ignored, number of affected rows you can see in the log file.
Following configuration options are available:
Action does not support transactions.
This action is useful to execute a bulk insert query in one transaction. An incoming message needs to contain a body with an array of objects.
You need to put the name of the table into field Table Name where you want to put multiple values.
For example, you need to execute following query:
INSERT INTO itemstable(id, text) VALUES (1, 'First item'), (2, 'Second item')
You need specify field Table Name = ‘itemstable’, Columns = ‘id, text’ and Values needs to be:
[
{
id: 1,
text: 'First item'
},
{
id: 2,
text: 'Second item'
}
]
All changes will rollback, if something wrong with data.
Expert mode. You can execute SQL query or SQL script in this action.
Put your SQL expression to SQL Query
for further execution. You can put only one
SQL query or several queries with delimiter ;
. All queries are executed in one
transaction. All changes will rollback if something wrong with one of the executions.
Also if you want to use prepared statements in your query, you need define prepared
statement variables like this way sqlVariableName = @MetadataVariableName:type
where:
sqlVariableName
- variable name in sql expression;MetadataVariableName
- variable name in metadata (it can be the same as sqlVariableName
);type
- type of variable , following types are supported:
string
(also default type if type is omitted)number
boolean
For example, for SQL expression SELECT * FROM tableName WHERE column1 = 'text' AND column2 = 15
you need to use following template: SELECT * FROM tableName WHERE column1 = @column1:string AND column2 = @column2:number
and put values into generated metadata.
Input metadata is generated from SQL Query
configuration field if this field
contains at least one defined value.
Output metadata is an array of arrays with the result of query execution and depends on the count of SQL queries which were executed. There is an empty array in output metadata, if execution does not return any results. For example, for an SQL script:
INSERT INTO tableOne (column1, column2) VALUES ('value1', 'value2');
SELECT * FROM table2;
the first SQL query INSERT INTO tableOne (column1, column2) VALUES ('value1', 'value2')
does not return any values and the second sql query SELECT * FROM table2
returns two records.
Output metadata for this example is:
[
[],
[
{
"col2": 123,
"col1": "abc"
},
{
"col2": 456,
"col1": "def"
}
]
]
Expert mode. You can execute SQL Injection in this action. You can not use prepare statement there, for this purpose use SQL Query Action.
Input metadata contains two fields:
SQL Expression
;Number of retries in case of deadlock transaction
.You can put there SQL query, SQL script or set of SQL queries from the previous
step. You can put only one SQL query or several queries with delimiter ;
.
All queries are executed in one transaction. All changes will rollback if
something wrong with one of the executions. For example, you have some file with
defined SQL script and want to execute this. You need to use some component
which can read this file on the previous step and return value like this:
{
"query_string": "INSERT INTO tableOne (column1, column2) VALUES ('value1', 'value2'); SELECT * FROM table2"
}
and in this action you need put query_string
(or some JSONata expression) to Sql Injection string
:
You can specify maximum number of retries, that is intended to help to solve
lock’s issues in case of a deadlock transaction. The delay between retries is 1
second. Default value for this configuration field is 0
, it means, that such
behavior is switched off (by default) and no any retry will be performed in case
of deadlocked transaction.
Output metadata is an array of arrays with the result of query execution and depends on the count of SQL queries which were executed. There is an empty array in output metadata, if execution does not return any results. For example, for SQL script:
INSERT INTO tableOne (column1, column2) VALUES ('value1', 'value2');
SELECT * FROM table2;
the first SQL query INSERT INTO tableOne (column1, column2) VALUES ('value1', 'value2')
does not return any values and the second SQL query SELECT * FROM table2
returns two records.
Output metadata for this example is:
[
[],
[
{
"col2": 123,
"col1": "abc"
},
{
"col2": 456,
"col1": "def"
}
]
]