Skip to main content
Solved

Truncate table before insert

  • November 9, 2021
  • 2 replies
  • 315 views

coldon
Contributor

I am trying to do an insert to CARTO table. It is mandatory to not drop the table because it is necessary anytime a table is created to make a specific SQL statement.

This table just has to have the last insert values so a truncate command is required.

I have tried with a SQL Executor with two statements. Truncate and Insert. What SQL Executor does is a truncate for every insert. At the end I have a table with only one row, the last value inserted.

Any ideas?

Best answer by nielsgerrits

You can use 2 SQLExecutors, one for one truncate and the other for the inserts. Using a Sampler and a FeatureHolder you should be able to run the truncate statement once and the insert statements after the truncate statement.

 

2021-11-09_15h24_43 

As an alternative you could use an Aggregator to merge all insertrows in one feature, then add a truncaterow above it.

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

2 replies

nielsgerrits
VIP
Forum|alt.badge.img+54
  • Best Answer
  • November 9, 2021

You can use 2 SQLExecutors, one for one truncate and the other for the inserts. Using a Sampler and a FeatureHolder you should be able to run the truncate statement once and the insert statements after the truncate statement.

 

2021-11-09_15h24_43 

As an alternative you could use an Aggregator to merge all insertrows in one feature, then add a truncaterow above it.


coldon
Contributor
  • Author
  • Contributor
  • November 10, 2021

Got it! Thank you!


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