Skip to main content
mstfo
Gold ⭐️
February 8, 2022
Solved

NiFi - How can i change ReplacementValue on ReplaceText ?

I'm using ExecuteSQL,SplitAvro,ConvertAvroToJSON,EvaluateJsonPath,ReplaceText,ExecuteSQL.

 

 

I am trying to replace the content in the flowfile using replaceText processor.

Now, i can replace like this. -> INSERT INTO values (${id},'${name}') . ReplaceText process like this : 

INSERT into x values(1,'xx')

INSERT into x values(2,'yy')

INSERT into x values(3,'zz')

I'm sending INSERT query for each line.

 

But i want to send executesql process like this

INSERT INTO x  values (1,'xx'),(2,'yy'),(3,'zz')

 

 

 

mstfo
mstfoAnswer
Gold ⭐️
February 10, 2022

I used MergeContent and i solved my problem. Thanks !

2 replies

araujo
Platinum ⭐️⭐️⭐️
Platinum ⭐️⭐️⭐️
February 8, 2022

The flow that you are trying to implement is not very efficient and it's hard to achieve what you want to do in that way.

You should try to refactor it using record-based processors, which is much simpler and more efficient to handle a large number of records.

 

Something like this: ExecuteSQLRecord -> QueryRecord -> PutDatabaseRecord

 

  • ExecuteSQLRecord - Query and stream records from the source database
  • QueryRecord - convert the records from the source to target format. (e.g. SELECT id, value FROM FLOWFILE)
  • PutDatabaseRecord - insert the converted records into the target database.

André

Translate
-- Was your question answered? Please take some time to click on "Accept as Solution" below this post. If you find a reply useful, say thanks by clicking on the thumbs up button.
mstfo
mstfoAuthorAnswer
Gold ⭐️
February 10, 2022

I used MergeContent and i solved my problem. Thanks !

Translate