You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81-13Lines changed: 81 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,25 +14,48 @@ Following actions are inside:
14
14
15
15
``LOOKUP BY PRIMARY KEY`` - this action will execute select query from specified table, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY"). The action returns only one result (a primary key is unique).
16
16
17
+
``UPSERT BY PRIMARY KEY`` - this action will execute select command from specified table, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"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).
18
+
17
19
``DELETE BY PRIMARY KEY`` - this action will execute delete query from specified table, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY"). The action returns an integer value that indicates the number of rows affected, the returned value can be 0 or 1 (a primary key is unique).
18
20
### How works
19
21
20
22
### Requirements
21
23
Before you can deploy any code into elastic.io **you must be a registered elastic.io platform user**. Please see our home page at [http://www.elastic.io](http://www.elastic.io) to learn how.
22
24
#### Environment variables
23
-
For unit-testing
25
+
For unit-testing is needed to specify following environment variables:
26
+
1. Connection to MSSQL:
27
+
-``CONN_USER_MSSQL`` - user login
28
+
-``CONN_PASSWORD_MSSQL`` - user password
29
+
-``CONN_DBNAME_MSSQL`` - DataBase name
30
+
-``CONN_HOST_MSSQL`` - DataBase host
31
+
-``CONN_PORT_MSSQL`` - DataBase port
32
+
2. Connection to MySQL:
33
+
-``CONN_USER_MYSQL`` - user login
34
+
-``CONN_PASSWORD_MYSQL`` - user password
35
+
-``CONN_DBNAME_MYSQL`` - DataBase name
36
+
-``CONN_HOST_MYSQL`` - DataBase host
37
+
-``CONN_PORT_MYSQL`` - DataBase port
38
+
3. Connection to Oracle:
39
+
-``CONN_USER_ORACLE`` - user login
40
+
-``CONN_PASSWORD_ORACLE`` - user password
41
+
-``CONN_DBNAME_ORACLE`` - DataBase name
42
+
-``CONN_HOST_ORACLE`` - DataBase host
43
+
-``CONN_PORT_ORACLE`` - DataBase port
44
+
4. Connection to PostgreSQL:
45
+
-``CONN_USER_POSTGRESQL`` - user login
46
+
-``CONN_PASSWORD_POSTGRESQL`` - user password
47
+
-``CONN_DBNAME_POSTGRESQL`` - DataBase name
48
+
-``CONN_HOST_POSTGRESQL`` - DataBase host
49
+
-``CONN_PORT_POSTGRESQL`` - DataBase port
24
50
#### Others
25
51
## Credentials
26
52
You may use following properties to configure a connection:
You can add the authorisation methods during the integration flow design or by going to your Settings > Security credentials > REST client and adding there.
29
55
### DB Engine
56
+
You are able to choose one of existing database types:
You are able to choose one of existing database types
32
-
-``MySQL`` - compatible with MySQL Server 5.5, 5.6, 5.7 and 8.0.
33
-
-``PostgreSQL`` - compatible with PostgreSQL 8.2 and higher
34
-
-``Oracle`` - compatible with Oracle Database 8.1.7 - 12.1.0.2
35
-
-``MSSQL`` - compatible with Microsoft SQL Server 2008 R2 and higher
58
+
36
59
### Connection URI
37
60
In the Connection URI field please provide hostname of the server, e.g. ``acme.com``
38
61
### Connection port
@@ -51,7 +74,7 @@ In the Password field please provide a password of the user that has permissions
51
74
Validation will start right after click on a Save button. You will be able to continue working with component after validation if all provided credentials will be valid.
52
75
## Triggers
53
76
### SELECT
54
-
You are able to provide SELECT queryOld with last execution timestamp as WHERE clause criteria.
77
+
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``.
57
80
During the first execution, date will be equal to ["start" of Unix Time](https://en.wikipedia.org/wiki/Unix_time) - ``1970-01-01 00:00:00.000``.
@@ -81,8 +104,8 @@ The format of ``Start Polling From (optional)`` field should be like ``yyyy-mm-d
The action will execute an [SQL](https://en.wikipedia.org/wiki/SQL"SQL")queryOld that can return multiple results, it has limitations on the queryOld and suited only for SELECT type of queries.
85
-
In SQL queryOld you can use clause variables with specific data types.
107
+
The action will execute an [SQL](https://en.wikipedia.org/wiki/SQL"SQL")query that can return multiple results, it has limitations on the query and suited only for SELECT type of queries.
108
+
In SQL query you can use clause variables with specific data types.
86
109
Internally we use prepared statements, so all incoming data is
87
110
validated against SQL injection, however we had to build a connection from JavaScript types to the SQL data types
88
111
therefore when doing a prepared statements, you would need to add ``:type`` to **each prepared statement variable**.
@@ -95,7 +118,7 @@ FROM users
95
118
WHERE userid = @id AND language = @lang
96
119
```
97
120
98
-
you should add ``:type`` to each ``@parameter`` so your SQL queryOld will looks like this:
121
+
you should add ``:type`` to each ``@parameter`` so your SQL query will looks like this:
99
122
100
123
```sql
101
124
SELECT
@@ -116,24 +139,69 @@ Following types are supported:
116
139
Checkbox ``Don't throw Error on an Empty Result`` allows to emit an empty response, otherwise you will get an error on empty response.
117
140
118
141
#### Input fields description
119
-
Component supports dynamic incoming metadata - as soon as your queryOld is in place it will be parsed and incoming metadata will be generated accordingly.
142
+
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 queryOld from a ``Table`` dropdown field, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY"). The action returns only one result (a primary key is unique).
146
+
147
+
The action will execute select query from a ``Table`` dropdown field, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY"). The action returns only one result (a primary key is unique).
124
148
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.
128
152
153
+
### UPSERT BY PRIMARY KEY
154
+
The action will execute ``SELECT`` command from a ``Tables`` dropdown field, as search criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"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).
155
+
1. Find and select jdbc-component in the component repository
As an input metadata you will get all fields of selected table. [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY") is required field (will mark as asterisk) and other input fields are optional.
The action will execute delete queryOld from a ``Table`` dropdown field, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY"). The action returns count of affected rows.
188
+
The action will execute delete query from a ``Table`` dropdown field, as criteria can be used only [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY"). The action returns count of affected rows.
132
189
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.
136
193
194
+
## Current limitations
195
+
1. Only tables with one [PRIMARY KEY](https://en.wikipedia.org/wiki/Primary_key"PRIMARY KEY") is supported. You will see the message ``Table has not Primary Key. Should be one Primary Key
196
+
``, if the selected table doesn't have a primary key. Also, you will see the message ``Composite Primary Key is not supported
197
+
``, if the selected table has composite primary key.
198
+
2. Only following versions of database types are supported:
199
+
-``MySQL`` - compatible with MySQL Server 5.5, 5.6, 5.7 and 8.0.
200
+
-``PostgreSQL`` - compatible with PostgreSQL 8.2 and higher
201
+
-``Oracle`` - compatible with Oracle Database 8.1.7 - 12.1.0.2
202
+
-``MSSQL`` - compatible with Microsoft SQL Server 2008 R2 and higher
203
+
3. 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 Exception ``Cannot 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.
0 commit comments