Execute stored procedure
This is an open source component for working with object-relational database management systems on elastic.io platform.
JDBC Component Completeness Matrix
You need to use following properties to configure credentials:
DB Engine
- Choose one of existing database types:
Connection URI
- Provide hostname of the server, e.g. acme.com
Connection port
- Optional field. Provide port of the server instance, as by default:
3306
- MySQL5432
- PostgreSQL1521
- Oracle1433
- MSSQL
Database Name
- Provide name of database at the instance that you want to interact with.
User
- Provide a username that has permissions to interact with the Database.
Password
- Provide a password of the user that has permissions to interact with the Database.
Configuration properties
- Optional field. Provide a configuration properties for connections to the Database, e.g. useUnicode=true&serverTimezone=UTC
Limitation: Configuration properties
value may not be checked during Credentials Verifacation, so in case of using this field make sure that it contains correct input.
You are able to provide SELECT query with last execution timestamp as WHERE clause criteria.
Before executing the the statement %%EIO_LAST_POLL%% will be replaced with ISO Date of the last execution or max value of the last pooled datetime, for example 2018-08-01T00:00:00.000
.
During the first execution, date will be equal to "start" of Unix Time - 1970-01-01 00:00:00.000
.
Precision of the polling clause can be till milliseconds.
The format of Start Polling From (optional)
field should be like yyyy-mm-dd hh:mi:ss[.sss]
, where
yyyy
- yearmm
- monthdd
- dayhh
- hourmi
- minutess
- secondsss
- millisecond (optional)
This trigger can polling data from provided table. As WHERE clause you can use column, which has datatype like DATE or TIMESTAMP.
Before executing the the statement %%EIO_LAST_POLL%% will be replaced with ISO Date of the last execution or max value of the last pooled datetime, for example 2018-08-01T00:00:00.000
.
During the first execution, date will be equal to "start" of Unix Time - 1970-01-01 00:00:00.000
.
Precision of the polling clause can be till milliseconds.
The format of Start Polling From (optional)
field should be like yyyy-mm-dd hh:mi:ss[.sss]
, where
yyyy
- yearmm
- monthdd
- dayhh
- hourmi
- minutess
- secondsss
- millisecond (optional)
Please Note: Component Snapshot will not be overwritten in Real-Time flows due to platform behaviour, so we strongly recommend to use Get Rows Polling trigger in Keen Flows only
Dropdown list with available table names, required field
Dropdown list with available Column names, that have a type like java.sql.Date
or java.sql.Timestamp
, required field
Optional field, indicates the beginning time to start polling from (defaults to the current time)
This action exists in JDBC component only for backward compatibility. New Select trigger is recommended to use.
Action to execute custom SQL query from provided request string.
Note: SQL request will be executed according to chosen database JDBC specification.
Execution result returns as array of objects. If request contains multiple sql statements - them will execute inside one transaction. If one of statements fails, transaction will be rollbacked.
As input metadata, you will get one field named query
to provide request string
Select:
SELECT name, size FROM stars
Update:
INSERT INTO stars values (1,'Taurus', '2015-02-19 10:10:10.0', 123, 5, 'true', '2015-02-19')
Posgresql batch multiple statements request:
DELETE FROM stars WHERE id = 1;
UPDATE stars SET radius = 5 WHERE id = 2;
The action will execute an SQL query that can return multiple results, it has limitations on the query and suited only for SELECT type of queries.
In SQL query you can use clause variables with specific data types.
Internally we use prepared statements, so all incoming data is
validated against SQL injection, however we had to build a connection from JavaScript types to the SQL data types
therefore when doing a prepared statements, you would need to add :type
to each prepared statement variable.
Note: prepared statement variables name could contain: any characters between a-z or A-Z, a digit and a character _
([a-zA-Z0-9_]
).
For example if you have a following SQL statement:
SELECT
FROM users
WHERE userid = @id AND language = @lang
you should add :type
to each @parameter
so your SQL query will looks like this:
SELECT
FROM users
WHERE userid = @id:number AND language = @lang:string
Following types are supported:
string
number
bigint
boolean
float
date
Dropdown Emit Behaviour contains following possible options:
- Fetch all - a single message with an array
results
containing all the objects (rows) will be emitted - Emit Individually - multiple messages (one message per one row) will be emitted
- Expect Single - a single message with one result row will be emitted. If more than one row is returned the error will be thrown. A boolean input "Allow Zero Results" (defaults to
false
) appears at input metadata. Iffalse
- error will be thrown, else - the empty object will be emitted.
Component supports dynamic incoming metadata - as soon as your query is in place it will be parsed and incoming metadata will be generated accordingly.
The action will execute select query from a Table
dropdown field, as criteria can be used only PRIMARY KEY. The action returns only one result (a primary key is unique).
Checkbox Don't throw Error on an Empty Result
allows to emit an empty response, otherwise you will get an error on empty response.
As an input metadata you will get a Primary Key field to provide the data inside as a clause value.
The action will execute INSERT
command into the table from Table
dropdown list the values specified in the body.
Enable Rebound
ifYes
in case of deadlocks rebound message using Sailor rebound mechanism, number of rebound can be specified via environment variable:ELASTICIO_REBOUND_LIMIT
recommended value 3
Action contains only one configuration field Table
- dropdown list with available table names.
As input metadata, you will get all fields of the selected table except for fields with auto-increment
or auto-calculated
property.
As output metadata, you will get execution insert result like:
{
"result": true
}
The action will execute delete query from a Table
dropdown field, as criteria can be used only PRIMARY KEY. The action returns count of affected rows.
Checkbox Don't throw Error on an Empty Result
allows to emit an empty response, otherwise you will get an error on empty response.
Enable Rebound
if Yes
in case of deadlocks rebound message using Sailor rebound mechanism, number of rebound can be specified via environment variable: ELASTICIO_REBOUND_LIMIT
recommended value 3
As an input metadata you will get a Primary Key field to provide the data inside as a clause value.
This action calls stored procedure from selected DB Schema
and Stored procedure
name
- DB Schema - a schema that contains a procedure to call. Must be selected from the dropdown list before
Stored procedure
name - Stored procedure - a name of a procedure to call, can be selected from the dropdown list
Metadata generates automatically using IN
& IN OUT
procedure parameters for input, and OUT
& IN OUT
procedure parameters for output.
As array fields this action now support ONLY:
- CURSOR (as SQL type)
- REF CURSOR (as ORACLE type) The result for this type of fields would be returned as an array of JSON objects.
This action DOES NOT processing MSSql @RETURN_VALUE.
-
For MySQL component same to DATABASE is same to SCHEMA by it's definition, so DB Schema dropdown is empty for MySQL.
-
MSSQL DB stored procedures has only IN and INOUT fields.
For Oracle DB procedure:
create PROCEDURE "INSERT_EMPLOYEE"(
i_emp_id IN EMPLOYEE.EMPID%TYPE,
i_name IN EMPLOYEE.EMPNAME%TYPE,
i_department IN EMPLOYEE.DEPARTMENT%TYPE)
IS
BEGIN
INSERT INTO EMPLOYEE (EMPID, EMPNAME, DEPARTMENT)
VALUES (i_emp_id, i_name, i_department);
END;
Component generates next metadata:
The action will execute SELECT
command from a Tables
dropdown field, as search criteria can be used only PRIMARY KEY, and execute INSERT
command by PRIMARY KEY with specified field, if result does not found, else - action will execute UPDATE
command by PRIMARY KEY with specified field. The action returns only one result row (a primary key is unique).
Enable Rebound
ifYes
in case of deadlocks rebound message using Sailor rebound mechanism, number of rebound can be specified via environment variable:ELASTICIO_REBOUND_LIMIT
recommended value 3 As an input metadata you will get all fields of selected table. PRIMARY KEY is required field (will mark as asterisk) and other input fields are optional.
This action exists in JDBC component only for backward compatibility. Please use Upsert row by primary key instead.
This action exists in JDBC component only for backward compatibility. Please use Select action instead.
- Only tables with one PRIMARY KEY is supported. You will see the message
Table has not Primary Key. Should be one Primary Key
, if the selected table doesn't have a primary key. Also, you will see the messageComposite Primary Key is not supported
, if the selected table has composite primary key. - Only following versions of database types are supported:
MySQL
- compatible with MySQL Server 5.5, 5.6, 5.7 and 8.0.PostgreSQL
- compatible with PostgreSQL 8.2 and higherOracle
- compatible with Oracle Database 8.1.7 - 12.1.0.2MSSQL
- compatible with Microsoft SQL Server 2008 R2 and higher
- The current implementation of the action
Upsert By Primary Key
doesn't mark non-nullable fields as required fields at a dynamic metadata. In case of updating such fields with an empty value you will get SQL ExceptionCannot insert the value NULL into...
. You should manually fill in all non-nullable fields with previous data, if you want to update part of columns in a row, even if data in that fields doesn't change. - The current implementation of the action
Execute stored procedure
doesn't support ResultSet MSSQL output. - The current implementation of the action
Execute stored procedure
doesn't support any array types parameters. (MySQL does not have schemas by definition) - Rebound mechanism only works for this SQL State:
MySQL
: 40001, XA102Oracle
: 61000MSSQL
: 40001PostgreSQL
: 40P01
- If your database server configured to custom timezone (differ from UTC) JDBC driver may convert time appropriate - for example if you want to use
Insert action
withMySQL
which is configured to+2:00
time zone and provide2022-01-01 15:00:00
as value to some datetime field in database it will be saved as2022-01-01 17:00:00
.
Apache-2.0 © elastic.io GmbH