FINALLY clause.
Data flows eliminate the need for external orchestration tools by allowing you to execute multiple SQL statements sequentially as a single unit. This approach simplifies pipeline logic, reduces round-trips between the application and database, and ensures cleanup always occurs, even when errors happen.
For details about data flow syntax and supported statements, see Data Flows.
Prerequisites
Before you begin, ensure that you have:- A running Ocient deployment with access to execute SQL statements.
- The
CREATE TABLEandINSERTprivileges on the target schema.
Prepare the Target Table
For the purposes of this tutorial, assume a source table namedraw_orders with these columns.
Create the target table that stores the final transformed results. This table holds aggregated order summaries by customer and region.
SQL
Build and Execute the ELT Pipeline
1
Build the Data Flow
Create a void data flow that stages raw data, applies transformations, and loads the results into the target table. The data flow performs these operations:Temporary tables use the
- Creates a temporary staging table
#valid_ordersto hold filtered records. - Creates a temporary aggregation table
#customer_aggto hold computed summaries. - Filters out canceled orders and inserts valid records into the staging table.
- Computes aggregated metrics per customer and region.
- Loads the aggregated results into the final
order_summarytable.
SQL
# prefix and the database scopes them to the data flow block. The system drops them automatically when the data flow completes.2
Verify the Results
Query the target table to verify that the data loaded correctly.
SQL
3
Add Error Handling
Optionally, you can wrap the transformation steps in the
TRY and EXCEPTION WHEN element to catch and handle errors gracefully. This example logs the error for diagnostics, then re-raises it so the data flow still aborts on failure.SQL

