Snap type: | Write | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
Description: | This Snap allows you to execute arbitrary SQL. Valid JSON paths that are defined in the where clause for queries/statements will be substituted with values from an incoming document. Documents will be written to the error view if the document is missing a value to be substituted into the query/statement.
| |||||||||
Prerequisites: | [None] | |||||||||
Support and limitations: |
| |||||||||
Account: | This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See PostgreSQL Account for information on setting up this type of account. | |||||||||
Views: |
| |||||||||
Settings | ||||||||||
Label | Required.The name for the Snap. You can modify this to be more specific, especiallyif especially if you have more than one of the same Snap in your pipeline. | |||||||||
SQL statement | Required.Specifies the SQL statement to execute on the server.
Scenario 1: Executing SQL statements without expressions
For example: Additionally, the JSON path (e.g. $myName) is allowed only in the WHERE clause. If the SQL statement starts with SELECT (case-insensitive), the Snap regards it as a select-type query and executes once per input document. If not, it regards it as write-type query and executes in batch mode. Scenario 2: Executing SQL queries with expressions
For example:
Known issue: The SQL statement will return a PGObject when returning non-standard types.
Default value: [None] | |||||||||
Pass through | If selected, the input document will be passed through to the output view under the key 'original'. This property applies only to the Execute Snaps with SELECT statement. Default value: Selected | |||||||||
Ignore empty result | If selected, no document will be written to the output view when a SELECT operation does not produce any result. If this property is not selected and the Pass through property is selected, the input document will be passed through to the output view. Default value: Not selected | |||||||||
Advanced properties | By default, the advanced properties are not required and is an empty table property. Press "+" button to add an advanced property if a value other than the default value should be set. | |||||||||
Properties: Auto Commit | Enter true or false. This advanced property applies only if the SQL statement property is a SELECT query. If the SQL statement property is of other types (e.g. INSERT, UPDATE, SELECT ... INTO, etc.), this property value is ignored. If the Auto commit in the account is set to true, the PostgreSQL JDBC driver stores the entire result set of a SELECT query before it provides the result set to the Snap. If the result set is larger than the available system memory, it may cause an "Out of Memory" situation, rendering the Snaplex node inoperative. Therefore, the Snap automatically turns off the Auto commit during the SELECT operation so that the JDBC driver streams result sets from the server to the Snap (the number of rows in each fetch of results from the driver is as specified in the account's "Fetch size" property). However, in some use cases (e.g. when using a PostgreSQL replica), the feature of automatic turning-off auto-commit may cause errors in the SELECT query if an UPDATE or INSERT query is being executed simultaneously in another Snap elsewhere in the same pipeline. In such cases, this advanced property can be used with 'Auto commit' = true to override the setting and prevent the error from being thrown. The "'Auto commit' = true" entry will force the Auto commit to "True" during the SELECT query execution. If the "'Auto commit' = true" entry causes out of memory because of the result set of SELECT query being larger than the available system memory, instead of using this advance property, the Fetch size property in the account can be used to prevent both out of memory and other errors. The value of Fetch size should be large enough to avoid the SELECT query error and small enough to prevent out of memory. Also, in such case, the larger the Fetch size is, the higher performance of the SELECT query operation. | |||||||||
Values | Default value: 'Auto commit' = false | |||||||||
Execute during preview | Enables you to execute the Snap during the Save operation so that the output view can produce the preview data. Default value: Not selected |
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|