Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Executing Multiple SQL Statements in Apache NiFi Database Workflows

avatar
New Member

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
New Member

@Matt

Thank you for your clarification.