Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Using this option creates a table with all columns of type STRING.

Snap type:

Write

Description:

This Snap executes a SQL Insert statement using the document's keys as the columns to insert to and the document's values as the values to insert into the columns.

 

Expected upstream Snaps:  The data to be written to table can be defined by providing values upstream. The document generator Snaps like JSON Generator can be used upstream. 

Expected downstream Snaps: The Snap will output one document for every record written, hence any document processing Snap can be used downstream. 

Table Creation

If the table does not exist when the Snap tries to do the insert and the Create table property is set, the table will be created with the columns and data types required to hold the values in the first input document. If you would like the table to be created with the same schema as a source table, you can connect the second output view of a Select Snap to the second input view of this Snap. The extra view in the Select and Insert Snaps are used to pass metadata about the table, effectively allowing you to replicate a table from one database to another.

 

The table metadata document that is read in by the second input view contains a dump of the JDBC DatabaseMetaData class. The document can be manipulated to affect the "CREATE TABLE" statement that is generated by this Snap. For example, to rename the "name" column to "full_name", you can use a Mapper Snap that sets the path "$.columns.name.COLUMN_NAME" to "full_name".  The document contains the following fields:

  • columns - Contains the result of the getColumns() method with each column as a separate field in the object.  Changing the "COLUMN_NAME" value will change the name of the column in the created table.  Note that if you change a column name, you do not need to change the name of the field in the row input documents.  The Snap will automatically translate from the original name to the new name.  For example, when changing from "name" to "full_name", the "name" field in the input document will be put into the "full_name" column.  You can also drop a column by setting the "COLUMN_NAME" value to null or the empty string.  The other fields of interest in the column definition are:
    • TYPE_NAME - The type to use for the column.  If this type is not known to the database, the DATA_TYPE field will be used as a fallback.  If you want to explicitly set a type for a column, set the DATA_TYPE field.
    • _SL_PRECISION - Contains the result of the getPrecision() method.  This field is used along with the _SL_SCALE field for setting the precision and scale of a DECIMAL or NUMERIC field.
    • _SL_SCALE - Contains the result of the getScale() method.  This field is used along with the _SL_PRECISION field for setting the precision and scale of a DECIMAL or NUMERIC field.
  • primaryKeyColumns - Contains the result of the getPrimaryKeys() method with each column as a separate field in the object.
  • declaration - Contains the result of the getTables() method for this table.  The values in this object are just informational at the moment.  The target table name is taken from the Snap property.
  • importedKeys - Contains the foreign key information from the getImportedKeys() method.  The generated "CREATE TABLE" statement will include "FOREIGN KEY" constraints based on the contents of this object.  Note that you will need to change the PKTABLE_NAME value if you changed the name of the referenced table when replicating it.
  • indexInfo - Contains the result of the getIndexInfo() method for this table with each index as aseparated field in the object.  Any UNIQUE indexes in here will be included in the "CREATE TABLE" statement generated by this Snap. 
Note

The Snap will not automatically fix some errors encountered during table creation since they may require user intervention to resolve correctly.  For example, if the source table contains a column with a type that does not have a direct mapping in the target database, the Snap will fail to execute.  You will then need to add a Data Snap to change the metadata document to explicitly set the values needed to produce a valid "CREATE TABLE" statement.


Prerequisites:

[None].

Support and limitations:

Works in Ultra Task Pipelines when the Batch Size is set to 1.

Account: 

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Configuring SAP HANA Accounts for information on setting up this type of account.

Views:


InputThis Snap has one input view by default that accepts the rows to insert into the table.  A second input view can be added that accepts the table metadata document from a database Select Snap. The table metadata will then be used to guide the creation of the table in the database.
OutputThis Snap has at most one output view. If an output view is available, a document will be written to the output view for every record inserted into the table.
Error

This Snap has at most one error view and produces zero or more documents in the view.

Note
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.



Settings

Label*

Required. The 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

The Specify the database schema name. In case it is not defined, then the suggestion for the Table Name will retrieve all tables names of all schemas. The property is suggestible and will retrieve available database schemas during suggest values.

Note

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

ExampleSYS
Default value: 
 [None]


Table name


The Specify the name of the table to execute insert on.

Note

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

Example: people

Default value:  [None]

Create table if not present

Whether the table should be automatically created if not already present.

Note
Multiexcerpt include macro
nameME_Create_Table_Automatically_2_Inputs
pageRedshift - Bulk Load

Default value:  Not selected

Preserve case sensitivity
Insert excerpt
MySQL - Insert
MySQL - Insert
nopaneltrue
Number of retriesSpecifies

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.

Example: 3

Default value: 0
Example: 3

Multiexcerpt include macro
nameretries
pageFile Reader

Retry interval (seconds)

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

Default value: 1Default value: 1
Example:  10

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute

Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute

Insert excerpt
Azure SQL - Bulk Load
Azure SQL - Bulk Load
nopaneltrue

 Examples


The following example illustrates how to insert data into a table. The table 'USER' is not existing on database initially. So the Snap will first creates the table 'USER' table.

First we pass the data we want to insert with a JSON Generator Snap:

Mapper will help map the data between JSON Generator and SAP HANA Insert Snaps.

Then we pass this data to SAP HANA Insert Snap to it and set up the table name USER under schema 'NEO_EY6W9QLUI3JQ38SLB5B5PDGKI'

Here is the sample output of the Snap:


Insert excerpt
SAP HANA Snap Pack
SAP HANA Snap Pack
nopaneltrue