Execute multiple SQL statements in a MySQL database

This example pipeline demonstrates how to execute multiple SQL statements within a single transaction using the MySQL Multi Execute Snap.



Download this Pipeline

  1. Configure the Mapper Snap to prepare SQL statements.

    In this example, the Mapper Snap creates an array of SQL statements to be executed:

    • INSERT statement to add a new employee record
    • UPDATE statement to modify an existing employee's salary
    • DELETE statement to remove an employee record
  2. Configure the MySQL Multi Execute Snap.

    The Snap is configured to execute all statements within a transaction:

    • SQL Statements: Reference the array of SQL statements from the input document using an expression.
    • Use Transaction: Selected to ensure all statements succeed or fail together.


  3. Validate and execute the pipeline.

    The MySQL Multi Execute Snap executes all SQL statements within a single transaction.

The pipeline successfully executes multiple SQL statements in a transaction. If any statement fails, all changes are rolled back.