Support Questions

Find answers, ask questions, and share your expertise

How to execute multiple SQL query in NIFI PUT SQL processor at a time?

avatar

How to execute multiple SQL queries in PutSql processor at a time

Ex: insert into table_a values('test_1'); insert into table_b values('test_2');
Flow:GetFile -> ReplaceText -> PutSQL -> PutFile

In the above flow ReplaceText processor will replace the flow file with above example query.

With this SQL flow file PutSql processor getting triggered and failed with error.

1 ACCEPTED SOLUTION

avatar
Master Mentor
@Saminathan A

The PutSQL processor expects that each FlowFile contains a single SQL statement and does not support multiple insert statements as you have tried above. You can have the GetFile Processor route its success relationship twice with each success going to its own ReplaceText processor. Each ReplaceText processor is then configured to create either the "table_a" or "table_b" insert statement. The success from both ReplaceText processors could then be routed to the same PutSQL processor.

Thanks,

Matt

View solution in original post

2 REPLIES 2

avatar
Master Mentor
@Saminathan A

The PutSQL processor expects that each FlowFile contains a single SQL statement and does not support multiple insert statements as you have tried above. You can have the GetFile Processor route its success relationship twice with each success going to its own ReplaceText processor. Each ReplaceText processor is then configured to create either the "table_a" or "table_b" insert statement. The success from both ReplaceText processors could then be routed to the same PutSQL processor.

Thanks,

Matt

avatar

@Matt

Thank you for your clarification.