<?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: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382520#M244613</link>
    <description>&lt;P&gt;OK, I see what is happening here. The QueryRecord is not needed and its giving you the error because its expecting Json format but its getting an insert sql statement that is created from the ConvertJsonToSQL processor. Does the record get inserted after the PutSQL gets executed on the insert statement? If so then the new id should be written as flowfile attribute "&lt;EM&gt;sql.generate.key&lt;/EM&gt;" and its not going to be part of the flowfile content. The QueryRecord is not needed here and its not used for this purpose. Each flowfile will have a content which is the actual data that it represents and attributes representing the metadata , when you list the flowfile click on the (i) icon in the first column and select the Attributes tab and it should be there with the new ID value. I got confused because the ConvertJsontoSQL is showing an error status in your screenshot&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2024 04:17:31 GMT</pubDate>
    <dc:creator>SAMSAL</dc:creator>
    <dc:date>2024-01-22T04:17:31Z</dc:date>
    <item>
      <title>From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382311#M244543</link>
      <description>&lt;P&gt;Dear all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a query regarding the insertion of a flowfile into a MySQL Database. Specifically, I would like to know how to retrieve the auto-incremented ID from the database and store it as a flowfile attribute.&lt;/P&gt;&lt;P&gt;Consider the following example flowfile (representing one record, with many more records in reality):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_0-1705480075163.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39447i06482A6EA57EB7D3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_0-1705480075163.png" alt="jarviszzzz_0-1705480075163.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My goal is to insert this data into 'table1,' which has an auto-incremented ID field (let's assume that after insertion, the ID will be 3001). Could you please guide me on how to retrieve this auto-incremented ID and assign it to a flowfile attribute?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jan 2024 08:31:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382311#M244543</guid>
      <dc:creator>jarviszzzz</dc:creator>
      <dc:date>2024-01-17T08:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382387#M244564</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/108694"&gt;@jarviszzzz&lt;/a&gt; ,&lt;/P&gt;&lt;P&gt;If you use the PutSQL process there is property called "Obtain Generated Keys" which is described as follows:&lt;/P&gt;&lt;P&gt;"&lt;EM&gt;If true, any key that is automatically generated by the database will be added to the FlowFile that generated it using the sql.generate.key attribute. This may result in slightly slower performance and is not supported by all databases&lt;/EM&gt;."&lt;/P&gt;&lt;P&gt;So basically you dont have to do anything extra besides setting this property to true. The new id should be written back as flowfile attribute which will be called "&lt;EM&gt;sql.generate.key&lt;/EM&gt;".&lt;/P&gt;&lt;P&gt;The PutSQL is very flexible, you can convert the json to SQL using the ConvertJsonToSQL processor and then use the PutSQL without specifying anything in the SQL Statement property, keep in mind that if you choose the ConvertJsonToSQL approach the fields names should match the target table column names as well as the data types should be compatible.&amp;nbsp; If the fields names dont match and\or you need some flexibility on how to insert the values, you can specify the sql insert statement in the Sql Statement property and use expression language to reference the different json field values but you need first to extract them into flowfile attributes using processor like EvaluateJsonPath and set the destination to flowfile attributes.&lt;/P&gt;&lt;P&gt;If that helps please accept solution.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 05:25:36 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382387#M244564</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-01-18T05:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382397#M244570</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for your reply!&lt;/P&gt;&lt;P&gt;However, I obtained this sql statement as output of the flowfile.&lt;/P&gt;&lt;P&gt;Please check below attachment (from data provenance)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_0-1705565916785.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39481i91155F090F471D1D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_0-1705565916785.png" alt="jarviszzzz_0-1705565916785.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Here is my setup for Putsql:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_1-1705565989956.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39482i9869D3633DE79202/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_1-1705565989956.png" alt="jarviszzzz_1-1705565989956.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Am I done something wrong?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 08:20:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382397#M244570</guid>
      <dc:creator>jarviszzzz</dc:creator>
      <dc:date>2024-01-18T08:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382443#M244588</link>
      <description>&lt;P&gt;what seems to be the issue? please provide more details . If you are getting any error messages please share&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 02:13:24 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382443#M244588</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-01-19T02:13:24Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382449#M244589</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Please refer to the attachment:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_0-1705637775198.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39494i0156F1659F89CEDF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_0-1705637775198.png" alt="jarviszzzz_0-1705637775198.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_5-1705637971364.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39499i9EFAA238A44A535C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_5-1705637971364.png" alt="jarviszzzz_5-1705637971364.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_2-1705637803853.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39496iFB109D10F8671504/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_2-1705637803853.png" alt="jarviszzzz_2-1705637803853.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_3-1705637812280.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39497i7C45C75BE7B5ABED/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_3-1705637812280.png" alt="jarviszzzz_3-1705637812280.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_4-1705637818114.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39498iD3F6327BE9E7478D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_4-1705637818114.png" alt="jarviszzzz_4-1705637818114.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For the "Queryrecord" Processor, I tried to select updated ID from flowfile.&lt;/P&gt;&lt;P&gt;How can I do that to obtain those new ids?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2024 04:19:39 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382449#M244589</guid>
      <dc:creator>jarviszzzz</dc:creator>
      <dc:date>2024-01-19T04:19:39Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382503#M244610</link>
      <description>&lt;P&gt;Can you provide screenshot of the ConvertAvroToJson processor? What is the output you are getting out of this processor?&lt;/P&gt;</description>
      <pubDate>Sun, 21 Jan 2024 04:49:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382503#M244610</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-01-21T04:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382519#M244612</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/80381"&gt;@SAMSAL&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_0-1705891505241.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39515i349D0B3C03FB840C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_0-1705891505241.png" alt="jarviszzzz_0-1705891505241.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Input from data provenance:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_1-1705891536816.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39516i1B36D57237075BE3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_1-1705891536816.png" alt="jarviszzzz_1-1705891536816.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jarviszzzz_2-1705891555034.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/39517i50EAF5A56940005B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jarviszzzz_2-1705891555034.png" alt="jarviszzzz_2-1705891555034.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 02:46:43 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382519#M244612</guid>
      <dc:creator>jarviszzzz</dc:creator>
      <dc:date>2024-01-22T02:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382520#M244613</link>
      <description>&lt;P&gt;OK, I see what is happening here. The QueryRecord is not needed and its giving you the error because its expecting Json format but its getting an insert sql statement that is created from the ConvertJsonToSQL processor. Does the record get inserted after the PutSQL gets executed on the insert statement? If so then the new id should be written as flowfile attribute "&lt;EM&gt;sql.generate.key&lt;/EM&gt;" and its not going to be part of the flowfile content. The QueryRecord is not needed here and its not used for this purpose. Each flowfile will have a content which is the actual data that it represents and attributes representing the metadata , when you list the flowfile click on the (i) icon in the first column and select the Attributes tab and it should be there with the new ID value. I got confused because the ConvertJsontoSQL is showing an error status in your screenshot&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 04:17:31 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382520#M244613</guid>
      <dc:creator>SAMSAL</dc:creator>
      <dc:date>2024-01-22T04:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: From FlowFile insert into MySQL, how do I return auto increment id value as flowfile attribute in Apache Nifi ?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382713#M244663</link>
      <description>&lt;P&gt;Thanks Samsal&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 06:33:52 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/From-FlowFile-insert-into-MySQL-how-do-I-return-auto/m-p/382713#M244663</guid>
      <dc:creator>jarviszzzz</dc:creator>
      <dc:date>2024-01-25T06:33:52Z</dc:date>
    </item>
  </channel>
</rss>

