Skip to main content
Solved

Use FeatureWriter to delete SQL table records

  • February 22, 2021
  • 3 replies
  • 292 views

Forum|alt.badge.img+1

Hi

Want to delete all rows from my SQL table. Created the following FeatureWriter to set to delete:FeatureWriter DeleteHowever, ran it in my workbench and the database records are still not deleted. Anything that I did wrong? Thanks.

Best answer by nielsgerrits

fmesafejde wrote:

Hi nielsgerrits,

Actually what I wanted to achieve is to delete all records in a SQL database table (far left) and then import from another source into the same table again:

FME 2Basically we just want to refresh the SQL table with new records. Hope this helps.

I think this technically should work, you only need one feature to initiate the FeatureWriter. You can do this by connecting a Creator transformer before the FeatureWriter. It does not matter what it does output, as it's only to start the FeatureWriter.

 

A more usual way to do this is to use the database function "Truncate" in the writer on the right side. It then removes all records from the table prior to inserting the new ones.

View original
Did this help you find an answer to your question?

3 replies

nielsgerrits
VIP
Forum|alt.badge.img+54

What is the input? A single feature to initiate the proces? Then you can change the Row Selection to Where Clause and enter 1=1. As this is always true it will delete all records.

 

Edit: I see you have put the Table Handling to Truncate Existing. From the documentation:

Truncate Existing: If destination table/list does not exist, the translation will fail. Otherwise, delete all rows from existing table or list.

So this feels not correct. What do you want to achieve? Do you want to write records to a table, and clean the table before writing? Then you just can use Insert and Truncate Existing.


Forum|alt.badge.img+1
  • Author
  • February 23, 2021

Hi nielsgerrits,

Actually what I wanted to achieve is to delete all records in a SQL database table (far left) and then import from another source into the same table again:

FME 2Basically we just want to refresh the SQL table with new records. Hope this helps.


nielsgerrits
VIP
Forum|alt.badge.img+54
  • Best Answer
  • February 23, 2021
fmesafejde wrote:

Hi nielsgerrits,

Actually what I wanted to achieve is to delete all records in a SQL database table (far left) and then import from another source into the same table again:

FME 2Basically we just want to refresh the SQL table with new records. Hope this helps.

I think this technically should work, you only need one feature to initiate the FeatureWriter. You can do this by connecting a Creator transformer before the FeatureWriter. It does not matter what it does output, as it's only to start the FeatureWriter.

 

A more usual way to do this is to use the database function "Truncate" in the writer on the right side. It then removes all records from the table prior to inserting the new ones.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings