Ya sorry.
Camel version: 3.15.0

On 23 March 2022 17:03:19 Andrea Cosentino <anco...@gmail.com> wrote:

Report the camel version, please

Il mer 23 mar 2022, 09:59 Reto Peter <reto.pe...@advanceit.ch> ha scritto:

Hi

I have a route with 2 following SQL INSERT commands.
One inserts into table A (CamelSqlGeneratedKeyRows is correct)
Next inserts into table B (CamelSqlGeneratedKeyRows is wrong, the value is
not updated, it remains the same)

I am using mySQL and Java 11

My simplified route:

from("file:{{dir.from.flowline.test}}?preMove=.inprogress&move=.done&delay=1000")
            .tracing()
            .log("Processing file: ${file:name}")
            .convertBodyTo(String.class)

.setHeader("CamelSqlRetrieveGeneratedKeys").simple("true")
            .to("sql:INSERT INTO files_from_partner(filename,
filecontent, partner_id) VALUES (:#${file:name},:#${body}, 1)")
            .log("${headers.CamelSqlGeneratedKeyRows}")
            .to("sql:INSERT INTO message_out(identifier) VALUES
(1)")
            .log("${headers.CamelSqlGeneratedKeyRows}");

Output when I process 1 files is:
Processing file: GDELR_1848540_BL-V2100029_55234 use it 4 TESTS II.xml
[{GENERATED_KEY=58}] correct
[{GENERATED_KEY=58}] wrong

Do I do something wrong, is it a bug?
I also tried to set the Header CamelSqlGeneratedColumns as follows:
@Component
class SetFilesFromPartnerKeyColumnsBean {
public void setKeys(String message, @Headers Map<String, Object>
outHeaders) {
     outHeaders.put("CamelSqlGeneratedColumns", new String[]
{"files_id"});
}
} And before executing the SQL INSERT in the route:
.bean(setFilesFromPartnerKeyColumnsBean)
But there was no effect, same results

MY workaround is with the "SELECT LAST_INSERT_ID()" which works but of
course not the way we should ...

Regards Reto



Sent with Aqua Mail for 
Android<https://play.google.com/store/apps/details?id=org.kman.AquaMail>
https://www.aqua-mail.com

Reply via email to