PostgreSQL Multi Execute

PostgreSQL Multi Execute

In this article

Overview

You can use this Snap to execute one or more SQL write statements sequentially inside a single transaction (BEGIN/END) for each input document. If one statement fails, all statements in that transaction are rolled back.

  • If an SQL statement fails, subsequent SQL statements are not executed, and error output is passed to the error view (if you select the option Route Error Data to Error View).

  • If all statements are successful, all output results are passed to the output view. 

postgresql-multi-execute-overview.png

 

Snap Type

The PostgreSQL - Multi Execute Snap is a Write-type Snap.

Support for Ultra Pipelines  

Works in Ultra Tasks

Known Issues

SELECT statements are not supported.

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: 0

  • Max: 1

  • Each input document should contain the data needed for variable substitution in your SQL statements.

  • When using multiple input documents, data can be written to both the output and error views.

  • Executes multiple write statements as a single transaction for every input document.

Output

Document

 

  • Min: 0

  • Max: 1

  • One output document per input document, regardless of the SQL statements executed.

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.

Snap Settings

  • Expression : JavaScript syntax to access SnapLogic Expressions to set field values dynamically (if enabled). If disabled, you can provide a static value. Learn more.

  • SnapGPT : Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.

  • Suggestion : Populates a list of values dynamically based on your Account configuration.

  • Upload : Uploads files. Learn more.

Learn more about the icons in the Snap Settings dialog.

Field Name

Field Type

Description

Field Name

Field Type

Description

Label*

 

 

String

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.


Default ValuePostgreSQL - Multi Execute
ExamplePostgreSQL - Multi Execute

SQL Statements*

Define the list of SQL statements to be executed as a single transaction.

SQL statement*

 

 

String/Expression

Specify the SQL statement to execute on the server.  


Default Value: N/A
Example:

  • drop table if exists public.snap_count1

  • create table public.snap_count1 (id int, name varchar(20))

  • insert into public.snap_count1 values (100, 'Jane')

Snap Execution

 

Dropdown list

Select one of the following three modes in which the Snap executes:

  • Validate & Execute: Performs limited execution of the Snap based on Preview Document Count value in User settings and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.

  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default ValueExecute only
Example: Validate & Execute

Example

Execute multiple statements using PostgreSQL Multi Execute Snap

This pipeline performs database table management operations on a PostgreSQL database. It executes multiple SQL statements in a sequence—it drops an existing table if it exists, creates a new table with specific schema, and inserts initial data into the newly created table.

ex-postgres-me-pipe-overview.png

Configure the PostgreSQL - Multi Execute Snap with the following SQL Statements:

  1. drop table if exists public.snap_count1: Drops the table public.snap_count1 if it exists.

  2. create table public.snap_count1 (id int, name varchar(20)): Creates a new table with columns id and name.

  3. insert into public.snap_count1 values (100, 'Jane'): Inserts a record with values into the newly created table.

ex-postgres-me-config.png

On validation, the pipeline executes the three SQL statements and displays the three SQL operations:

  • Drop Table Result - Status of dropping the existing 'public.snap_count1' table (if it existed) (success)

  • Create Table Result - Status of creating the new 'public.snap_count1' table with 'id' and 'name' columns. Count for each SQL statement

  • Insert Data Result - Status of inserting the initial record into the newly created table

ex-postgresql-multi-execute-output.png

After successful execution, you'll have:

  • A new PostgreSQL table named public.snap_count1

  • The table will contain the initial data record that was inserted.

  • The table will have the defined id and namenames.

Download this pipeline

Downloads

  1. Download and import the pipeline into the SnapLogic application.

  2. Configure Snap accounts, as applicable.

  3. Provide pipeline parameters, as applicable.

 

  File Modified

File Example-PostgreSQL-MultiExecute-Snap.slp

Sept 05, 2025 by Kalpana Malladi

Snap Pack History


Related Content