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

Snap type:

Write


Description:

This Snap executes a SQL update with the given properties. Document keys will be used as the columns to update, and their values will be used as the updated value.

Note
Updates will be batched up until the account's batch size property or until the structure of the update statement changes. An update statement will change if an incoming document contains different keys than a previous document. 


Prerequisites:

None


Support and limitations:Works in Ultra Pipelines.
Account: 

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


Views:


Input

This Snap allows exactly one input view. 

OutputThis Snap has at most one output view. If an output view is available, then the original document that was used to create the statement will be output with the status of the update.
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 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 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 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

Required. The name of the table to execute the update operation on.

Note

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

Example: people

Default value:  [None]


Update condition

Required. The condition to execute an update on.

Note

Instead of building multiple Snaps with inter dependent DML queries, it is recommended we recommend you to use the Oracle - Stored Procedure or the Multi Execute Snap.
In a scenario where 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.

Examples

Multiexcerpt macro
nameME_DB_Snaps_Query_Examples

Without using expressions

  • email = 'you@example.com' or email = $email 
  • emp=$emp

Using expressions

  • "EMPNO=$EMPNO and ENAME=$EMPNAME"
  • "emp='" + $emp + "'"
  • "EMPNO=" + $EMPNO + " and ENAME='" + $EMPNAME+ "'"
Caution

Using expressions that join strings together to create SQL queries or conditions has a potential SQL injection risk and hence unsafe. Ensure that you understand all implications and risks involved before using concatenation of strings with '=' Expression enabled. 


Default value:  [None]

Note

If Batch size in your account is greater than one, do not toggle on the expression button if a dynamic argument needs to be defined referencing several input documents.


Number of retries

Specifies 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

Retry interval (seconds)

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

Example:  10

Default value: 1

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute

Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute

Excerpt Include
Azure SQL - Bulk Load
Azure SQL - Bulk Load
nopaneltrue


Examples



Expand
title1. Update a record in a table

In this example, we will update a record in a table.


 


This example updates a row of data in table TEST_EMPLOYEE which is defined as below:

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

We need to change the Title column of the row that has "Cooper" as Employee_Name to "Senior Software Engineer". First we use a JSON Generator Snap to pass the new data:


 


Then we set up the table name and the update condition:

This is an example output of the pipeline: 

 


Expand
title2. Error handling

In this example, we will see how error handling works.

We are using the same pipeline as the one used in Example #1. The difference is this time we try to update the column "Titlee" which doesn't exist in TEST_EMPLOYEE table:


 


And this is the error message routed to the error view: 

 



Expand
title3. Northwind sample database

In this example, we will use the well-known Northwind sample database.
 

Following is a selection from the "Customers" table:


CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1
 
Alfreds FutterkisteMaria AndersObere Str. 57Berlin12209Germany
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico
4
 
Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
5Berglunds snabbköpChristina BerglundBerguvsvägen 8LuleåS-958 22Sweden
 


Assume we wish to update the customer "Alfreds Futterkiste" with a new contact person and city.


Enter Customers in the Table name property and CustomerName='Alfreds Futterkiste' in the Update condition property.


Assume that the Update Snap receives a Map data in the input view as following:

Code Block
{ "ContactName" : "Alfred Schmidt", "City" : "Hamburg" }
  
Code Block
UPDATE Customers SET ContactName='Alfred Schmidt', City='Hamburg' WHERE CustomerName='Alfreds Futterkiste';

and submit the request to the database server.

 
The selection from the "Customers" table will now look like this:
 

CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1
 
Alfreds FutterkisteAlfred SchmidtObere Str. 57Hamburg12209Germany
2Ana Trujillo Emparedados y heladosAna TrujilloAvda. de la Constitución 2222México D.F.05021Mexico
3Antonio Moreno TaqueríaAntonio MorenoMataderos 2312México D.F.05023Mexico
4
 
Around the HornThomas Hardy120 Hanover Sq.LondonWA1 1DPUK
5Berglunds snabbköpChristina BerglundBerguvsvägen 8LuleåS-958 22Sweden
 


Be careful when updating records. If we had omitted the Update condition property in the example above, the "Customers" table would have looked like this:


CustomerIDCustomerNameContactNameAddressCityPostalCodeCountry
1
 
Alfreds FutterkisteAlfred SchmidtObere Str. 57Hamburg12209Germany
2Ana Trujillo Emparedados y heladosAlfred SchmidtAvda. de la Constitución 2222Hamburg05021Mexico
3Antonio Moreno TaqueríaAlfred SchmidtMataderos 2312Hamburg05023Mexico
4
 
Around the HornAlfred Schmidt120 Hanover Sq.HamburgWA1 1DPUK
5Berglunds snabbköpAlfred SchmidtBerguvsvägen 8HamburgS-958 22Sweden
 



Excerpt Include
Oracle Snap Pack
Oracle Snap Pack
nopaneltrue