1

Requirement: From an UI I am getting selected list of tables of a database. Data from these tables are to extracted and stored in file location. We are expected to use NiFi Rest APIs as there is a requirement for custom UI. So we are invoking NiFi processors using REST APIs.

Issue: With ExecuteSQL processor I can execute one SQL query at a time. Since the query is same for all of the tables (select * ...) I can pass in the table name as an attribute to the processor. But I am getting the table names from a REST API call so its delimited string.

the issue is how to invoke the ExecuteSQL in a loop for each table name received in a delimited String.

Kindly let me know if additional information is required.

2
  • provide how you are getting tables names in the flowfile? Commented Jun 19, 2018 at 3:52
  • We are getting the tables from InvokeHTTP processor Commented Jun 20, 2018 at 5:25

1 Answer 1

2

ExecuteSQL can't loop on a single flow file. Instead you can use ReplaceText to put the delimited string into the body of the flow file, then use SplitText to split on the delimiter. You will get multiple flow files, each with the body containing one of the fields. Then you can use ReplaceText again to match the entire text, and replace with the SELECT statement around the group:

SELECT * from $1

Then you can send all flow files to ExecuteSQL, it will execute each SELECT one at a time (or concurrently if you set multiple concurrent tasks.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot mattyb for the so quick response! Will try what you have suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.