Delete DB table
Delete rows from STG_SALES_DATA using transformation-driven criteria.
Workshop - Delete DB table
Delete rows from STG_SALES_DATA based on criteria in a stream.
This workshop uses a product line list and a minimum quantity threshold.
Use this step when your delete logic is driven by transformation output. Use Execute SQL script for simple deletes.
What you’ll do
Inspect the target table before you delete
Build a delete criteria stream (product line + quantity)
Delete matching rows with Delete
Validate results with SQL
Prerequisites
STG_SALES_DATAexists. Create it in Create DB table.A working database connection. See Database Connections.
Estimated time: 20 minutes
Workshop files
Create a file named productlines.csv.
Save it in the same folder as your transformation.
This workshop assumes a single-column file with no header row:
Classic Cars
Motorcycles
Planes
Ships
Trains
Trucks and Buses
Vintage CarsBack up your table before you run deletes. You can copy the table, or use a database snapshot.

Create a new transformation
Use any of these options to open a new transformation tab:
Select File > New > Transformation
Use
Ctrl+N(Windows/Linux) orCmd+N(macOS)
Inspect the data
Inspect STG_SALES_DATA before you delete.
You need a baseline to validate the change.
In your database tool, view
STG_SALES_DATA.

You will filter deletes using PRODUCTLINE and QUANTITYORDERED.
Run a quick check for high-quantity rows:

Start Spoon.
Drag the CSV File Input step onto the canvas.
Open the CSV File Input properties dialog box.
Configure it to read:
${Internal.Transformation.Filename.Directory}/productlines.csvSelect Get Fields.

Delete
Delete is a terminal step. It does not pass rows downstream.
It builds DELETE statements from the input stream.
Be careful with the comparators in this step. Always validate your criteria before you run.
Drag the Delete step onto the canvas.
Open the Delete properties dialog box.
Configure the database Connection and set Table name to
STG_SALES_DATA.Map stream fields to table fields for your delete criteria.

This workshop uses criteria based on:
QUANTITYORDEREDand themin_quantityorderedvaluePRODUCTLINEvalues fromproductlines.csv
Troubleshooting
Nothing was deleted Your criteria did not match any rows. Confirm your comparator and data types.
Too many rows deleted Your comparator is too broad, or you mapped the wrong field names.
Delete step fails with type conversion errors
Cast min_quantityordered to a number with Select values.
Last updated
Was this helpful?



