Oracle - Insert

On this Page

Overview

You can use this Snap to execute an SQL Insert statement. Document keys are used as the columns to insert into, and their values are inserted into the column. Any missing column will insert a null value into it.

oracle-insert-overview.png

Snap Type

The Oracle - Insert Snap is a Write-type Snap that inserts the specified data in the target table.

Prerequisites

Support for Ultra Pipelines  

Known Issues

The Oracle - Insert Snap inserts incorrect time zone data for timestamp with time zone data type. For example, when an input value is 2021-08-10 17:30:43-07:00, the value written to the target table is 2021-08-10 17:30:43+07:00.

Workaround:
Use an expression Date.parse(2021-08-10 17:30:43-07:00) in Mapper Snap. The Mapper Snap converts it to a UTC timestamp string, that is, 2021-08-11 00:30:43 00:00. The Snap will now insert the value successfully.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

 

  • Min: 1

  • Max: 2

  • Mapper

  • Copy

Requires the Schema name and Table name to process a certain number of input documents into a prepared insert query.

The second input view can be added for metadata for the table as a document so that the table is created in Oracle with a similar schema as the source table. If the table already exists, then the metadata is not used.

Output

Document

 

  • Min: 0

  • Max: 1

  • Mapper

Snap outputs the number of documents successfully inserted into the target table in the output view document.

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • Stop Pipeline Execution: Stops the current pipeline execution if the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution. Learn more about Error handling in Pipelines.

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 Name

Field Type

Description

Field Name

Field Type

Description

Label*

Default valueOracle - Insert
Example: Insert Emp data

 

String

Specify the 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.

Schema name


Default value:  N/A
ExampleSYS

 

 

String/Expression/Suggestion

Specify the database schema name. The suggestions in the Schema field are populated only when at least a single table exists in the schema. If no tables exist to use that schema, only SYS, SYSTEM, and XDB are populated.



Table name


Default value:  N/A
Examplepeople

String/Expression/Suggestion

Specify the table that the rows will be inserted into. This list is populated based on the tables associated with the selected schema.

 

Create table if not present

 

Default stateDeselected

 

Checkbox

Learn more about table creation.

Preserve case sensitivity

Checkbox

Select this checkbox to preserve the case sensitivity of the column names while performing the insert operation.

  • If you deselect the Preserve case sensitivity checkbox, the input documents are loaded to the target table if the key names in the input documents match the target table column names ignoring the case.

  • If you include a second input view, selecting this checkbox has no impact on the column names of the target table, because the Snap uses the metadata from the second input view.

Number of retries

 

Default value: 0
Example3

Integer/Expression

Specify the maximum number of attempts to be made to receive a response. The request is terminated if the attempts do not result in a response.

Retry interval (seconds)

 

Default value: 1
Example: 10

Integer/Expression

Specify the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception. 

Session parameters

Use this field set to define the session parameters. This property lets you use the National Language Support (NLS) parameters. See the Oracle doc for detailed information about Setting NLS Parameters.

The NLS parameters enable overriding the default value (e.g., a comma) that is set for the session in the initialization parameter file or set by the client with environment variables (e.g., a decimal point).

You can add multiple parameters by using the plus (+) sign next to Session parameters.

Session parameter name

Default value: N/A
Example: NLS_TERRITORY

String/Expression

Name of the NLS parameter.

  • This Snap supports the Enable, Disable, and Force commands in session parameters.

  • This field supports only pipelines parameters, and not upstream values.

 

Session parameter value

Default value: N/A
Example: "CZECH REPUBLIC"

String/Expression

Value of the NLS parameter. This field supports only pipelines parameters, and not upstream values.

 

Dropdown list

Specify the database schema name. Selecting a schema, filters the Table name list to show only those tables within the selected schema. The suggestions in the Schema field are populated only when at least a single table exists in the schema. If no tables exist to use that schema, only SYS, SYSTEM, and XDB are populated.

The values can be passed using the pipeline parameters but not the upstream parameter.

Auto commit

In a scenario where the Auto commit on the account is set to true, and the downstream Snap does depends on the data processed on an Upstream Database Bulk Load Snap, use the Script Snap to add delay for the data to be available.

For example, when performing a create, insert and a delete function sequentially on a pipeline, using a Script Snap helps in creating a delay between the insert and delete function or otherwise it may turn out that the delete function is triggered even before inserting the records on the table.

Oracle reports failures for the entire batch even if some rows successfully inserted/updated. Because the Snap must report what is reported by the database, the Snap sends all records to the error view and no record to the output view. If you want to see accurate results for each row you must set the batch size to 1 and execute the pipeline. 

Examples

Insert input data into a table

The following example pipeline demonstrates how to insert a row of data into TEST_EMPLOYEE table.

ex1-pipeline-overview.png

Table dataset:

CREATE TABLE "TECTONIC"."TEST_EMPLOYEE" ( "Title" VARCHAR2(4000 BYTE), "Employee_Name" VARCHAR2(4000 BYTE), "Employee_ID" VARCHAR2(4000 BYTE) );

Step 1: Configure the JSON Generator Snap with the data you want to insert into the target table.

Step 2: Configure the Oracle - Insert Snap as shown below to insert this data into the TEST_EMPLOYEE table.

On validation, Snap inserts the employee details into the target TEST_EMPLOYEE table and displays the “success” message in the output.

 

Error Handling of the Snap

This example pipeline demonstrates error handling.

Use the same pipeline as the one used in Example 1. Insert a row with a non-existing column name "Titlee". In the Oracle - Insert Snap, choose Route Error Data to Error View under the Views tab.

On validation, the error message is routed to Snap's error view:


Snap Pack History