pfx-sql:delete

Summary: Delete records from an external SQL database table that match a specified filter.


URI Format

pfx-sql:delete?table=myTable&filter=myFilter&dataSource=myDb

Parameters

Parameter

Type

Default

Required

Description

dataSource

String

dataSource

No

Name of the Spring DataSource bean

table

String


Yes

Target database table

filter

String


Yes

Filter reference that determines which records to delete

dialect

SQLDialect

MYSQL

No

SQL dialect

Examples

Delete Inactive Products

XML
<route id="deleteInactive">
    <from uri="timer://cleanup?repeatCount=1"/>
    <to uri="pfx-sql:delete?table=products&amp;filter=inactiveFilter&amp;dataSource=myDb"/>
</route>

Delete with Specific Dialect

XML
<route id="deleteFromOracle">
    <from uri="timer://cleanup?repeatCount=1"/>
    <to uri="pfx-sql:delete?table=old_transactions&amp;filter=expiredFilter&amp;dataSource=oracleDb&amp;dialect=ORACLE"/>
</route>

Delete Before Reload Pattern

XML
<route id="deleteAndReload">
    <from uri="timer://sync?repeatCount=1"/>
    <!-- Delete stale records first -->
    <to uri="pfx-sql:delete?table=products&amp;filter=staleFilter&amp;dataSource=myDb"/>
    <!-- Then reload fresh data -->
    <to uri="pfx-api:fetch?objectType=P&amp;filter=activeProducts"/>
    <to uri="pfx-sql:insert?table=products&amp;mapper=dbMapper&amp;dataSource=myDb"/>
</route>

Common Pitfalls

Problem

Cause

Fix

No records deleted

Filter does not match any rows

Verify the filter logic matches existing data

All records deleted unexpectedly

Filter is too broad

Review filter definition; consider using truncate if intentional

Missing filter parameter

Required parameter not provided

Add filter=yourFilter to the URI

Missing table parameter

Required parameter not provided

Add table=yourTable to the URI

See Also

  • pfx-sql Component — Parent reference

  • pfx-sql:truncate — Remove all rows (no filter needed)