Oracle - Execute
In this article
Overview
You can use this Snap to execute an Oracle statement or query. This is a Write Snap type. This Snap works only with single queries.
This Snap:
- is for simple DML (SELECT, INSERT, UPDATE, DELETE) type statements. For the comprehensive scripting functionality offered by various databases, use stored procedure functionality offered by their chosen database using the Stored Procedure Snap.
- might drop your database, hence be cautious.
- If you execute a SELECT query, the query's results are merged into the incoming document and the values of any existing keys will be overwritten. On the other hand, if there are no results from the query, the original document is written.
- Any valid JSON paths that you define in the WHERE clause for queries/statements are 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.
Upcoming
Prerequisites
None.
Support for Ultra Pipelines
Works in Ultra Pipelines.
Limitations
- Due to the limitation in Oracle JDBC driver, the SQL statement cannot have semicolons at the end except that it is a BEGIN-END block.
- This Snap cannot invoke procedures, hence we recommend that you use Oracle Stored Procedure Snap for invoking procedures.
Known Issues
When the SQL statement property is an expression, the Pipeline parameters are shown in the Suggest, but not the input schema.
Behavior Change
In 4.26, when the stored procedures were called using the Database Execute Snaps, the queries were treated as write queries instead of read queries. So the output displayed message and status keys after executing the stored procedure.
In 4.27, all the Database Execute Snaps run stored procedures correctly, that is, the queries are treated as read queries. The output now displays message key, and OUT params of the procedure (if any). The status key is not displayed.If the stored procedure has no OUT parameters then only the message key is displayed with value success.
If you have any existing Pipelines that are mapped with status key or previous description then those Pipelines will fail. So, you might need to revisit your Pipeline design.
- As part of
main23721
(because of the JOOQ upgrade) previously, when you used a stored procedure in the Oracle-Execute Snap, the Snap displayed aMessage:Success
in the output. Now, the Snap displays$UPDATE_COUNT=-1
. As part of
436patches25696
, when you use a stored procedure in the Oracle - Execute Snap, the Snap displaysMessage: Success
and$UPDATE_COUNT=-1, 0, or 1
(based on the Snap Pack behavior) in the output.
Snap Input and Output
Input/Output | Type of view | Number of views | Examples of Upstream/Downstream Snap | Description |
---|---|---|---|---|
Input | Document |
|
| This Snap has at most one document input view. If the input view is defined, then the where clause can substitute incoming values for a given expression. |
Output | Document |
|
| This Snap has at most one document output view. If an output view is available and an update/insert/merge/delete statement was executed, then the original document that was used to create the statement will be output with the status of the statement executed. Database Write Snaps output all records of a batch (as configured in your account settings) to the error view if the write fails during batch processing. |
Snap Settings
Field | Field Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Label* | String | Enter a unique name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your Pipeline. Default Value: Oracle Execute | ||||||||||
SQL statement* | String | Specify the SQL statement to execute on the server. Executing SQL statements in SnapLogic You must understand the following scenarios to successfully execute your SQL statements: Scenario 1: Executing SQL statements without expressions
Examples:
Additionally, the JSON path 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. If your Oracle table has columns whose names contain a '$' (or any other special character) in it, enclose the column name within quotes, such as: Scenario 2: Executing SQL queries using expressions
Table name and column names must not be provided as bind parameters. Only values can be provided as bind parameters. Examples:
We recommend you to use the Oracle Stored Procedure Snap for invoking procedures as the Oracle Execute Snap has the following limitation while invoking procedures:
Oracle JDBC documentation recommends using Single quotes in values must be escaped Any relational database (RDBMS) treats single quotes ( For example:
Default Value: [None] | ||||||||||
Query type | Dropdown list/Expression | Select the type of query for your SQL statement (Read or Write). When Auto is selected, the Snap tries to determine the query type automatically. Default Value: Auto | ||||||||||
Pass through |