Oddly enough, the SQL component reset the CamelSqlUpdateCount header value to zero when there is a 'SET FOREIGN_KEY_CHECKS' before a 'REPLACE SELECT'.
I ran in debug mode with a watcher on the header map. Yes the value is correct at first but it is set to zero in the process.
This situation does not occur with the JDBC component, only with the SQL component. Unfortunately, the JDBC component cannot be used in a "from".
working.sql
REPLACE INTO TABLE_B
SELECT * FROM TABLE_A;
SET FOREIGN_KEY_CHECKS = 1;
non_working.sql
SET FOREIGN_KEY_CHECKS = 0;
REPLACE INTO TABLE_B
SELECT * FROM TABLE_A;
SET FOREIGN_KEY_CHECKS = 1;
Working route
.enrich("sql:working.sql") // CamelSqlUpdateCount header is set e.g. to 500
.process(MyClass::operation) // CamelSqlUpdateCount is still 500
Non-working route
.enrich("sql:non_working.sql") // CamelSqlUpdateCount header is set e.g. to 500
.process(MyClass::operation) // CamelSqlUpdateCount has been lost, it is zero
Camel version 3.12.0