<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: nifi - Writing/Inserting entire flowfile content in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205370#M59745</link>
    <description>&lt;P&gt;It worked. Thanks a lot..!! I was using 'ALWAYS REPLACE'  instead of 'Regex Replace'&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2017 05:35:13 GMT</pubDate>
    <dc:creator>shamjithnair</dc:creator>
    <dc:date>2017-04-21T05:35:13Z</dc:date>
    <item>
      <title>nifi - Writing/Inserting entire flowfile content</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205367#M59742</link>
      <description>&lt;P&gt;I have JSON input. I need to insert  a database table column with  the entire content of that JSON.&lt;/P&gt;&lt;P&gt;Flow is as follows,&lt;/P&gt;&lt;P&gt;Read a JSON from kafka then insert a record in a database. column A with one particular value of the input JSON and Column B with entire JSON.&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Shamji&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 10:42:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205367#M59742</guid>
      <dc:creator>shamjithnair</dc:creator>
      <dc:date>2017-04-20T10:42:42Z</dc:date>
    </item>
    <item>
      <title>Re: nifi - Writing/Inserting entire flowfile content</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205368#M59743</link>
      <description>&lt;P&gt;You can use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.EvaluateJsonPath/index.html"&gt;EvaluateJsonPath&lt;/A&gt; to extract the one particular value of the input JSON into an attribute, then you can use &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.ReplaceText/index.html"&gt;ReplaceText&lt;/A&gt; to create a SQL statement (using &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html"&gt;NiFi Expression Language&lt;/A&gt; and group referencing, see ReplaceText documentation for more details) that refers to both the extracted attribute and the incoming flow file content. Then you can send that to &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi.processors.standard.PutSQL/index.html"&gt;PutSQL&lt;/A&gt; to insert into the database.&lt;/P&gt;&lt;P&gt;For example, if you have the following JSON:&lt;/P&gt;&lt;PRE&gt;{
  "id": 100,
  "user" : {
    "name": "Joe Smith",
    "email": "jsmith@mycompany.com",
    "age": 42
  }
}&lt;/PRE&gt;&lt;P&gt;And you have a database table called "myTable" with two columns, "id" and "json". Then you could use EvaluateJsonPath to set an attribute "json.id" with a JSONPath expression of "$.id". The the ReplaceText could replace the whole content with something like the following:&lt;/P&gt;&lt;PRE&gt;INSERT INTO myTable VALUES (${json.id}, '$1')&lt;/PRE&gt;&lt;P&gt;I haven't tried this to see if it works as-is, but that is the basic approach. You may have to do something with &lt;A target="_blank" href="https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#escapejson"&gt;escaping the JSON&lt;/A&gt; or quote characters or something like that.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 20:13:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205368#M59743</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2017-04-20T20:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: nifi - Writing/Inserting entire flowfile content</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205369#M59744</link>
      <description>&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;I tried that. $1 is not getting replaced with JSON. I was using the same processors for this purpose. &lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 23:25:30 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205369#M59744</guid>
      <dc:creator>shamjithnair</dc:creator>
      <dc:date>2017-04-20T23:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: nifi - Writing/Inserting entire flowfile content</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205370#M59745</link>
      <description>&lt;P&gt;It worked. Thanks a lot..!! I was using 'ALWAYS REPLACE'  instead of 'Regex Replace'&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 05:35:13 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/nifi-Writing-Inserting-entire-flowfile-content/m-p/205370#M59745</guid>
      <dc:creator>shamjithnair</dc:creator>
      <dc:date>2017-04-21T05:35:13Z</dc:date>
    </item>
  </channel>
</rss>

