<?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 Managing multiple insert queries in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226711#M188571</link>
    <description>&lt;P&gt;Hi everyone. &lt;/P&gt;&lt;P&gt;I have two ReplaceText Processors injecting two different insert queries into a single PutSQL Processor (my insert queries use values coming from elements of two xml files). &lt;/P&gt;&lt;P&gt;My goal is to make sure that if an insert fails then a rollback operation is performed on the other (assuming it doesn't fail), because I don't have to create a mismatch between the tables. &lt;/P&gt;&lt;P&gt;How can I obtain such a feature? &lt;/P&gt;&lt;P&gt;Any help will be appreciated. &lt;/P&gt;</description>
    <pubDate>Thu, 01 Mar 2018 23:44:46 GMT</pubDate>
    <dc:creator>basiler82</dc:creator>
    <dc:date>2018-03-01T23:44:46Z</dc:date>
    <item>
      <title>Managing multiple insert queries</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226711#M188571</link>
      <description>&lt;P&gt;Hi everyone. &lt;/P&gt;&lt;P&gt;I have two ReplaceText Processors injecting two different insert queries into a single PutSQL Processor (my insert queries use values coming from elements of two xml files). &lt;/P&gt;&lt;P&gt;My goal is to make sure that if an insert fails then a rollback operation is performed on the other (assuming it doesn't fail), because I don't have to create a mismatch between the tables. &lt;/P&gt;&lt;P&gt;How can I obtain such a feature? &lt;/P&gt;&lt;P&gt;Any help will be appreciated. &lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 23:44:46 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226711#M188571</guid>
      <dc:creator>basiler82</dc:creator>
      <dc:date>2018-03-01T23:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Managing multiple insert queries</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226712#M188572</link>
      <description>&lt;P&gt;You can use &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.PutDatabaseRecord/index.html" target="_blank"&gt;PutDatabaseRecord&lt;/A&gt; instead of ReplaceText -&amp;gt; PutSQL, it will take the data itself and generate/execute the necessary SQL for your inserts. It also supports "Rollback on Failure" which should give you the error handling behavior you're looking for. You'll need to configure a RecordReader, and there isn't currently an XML RecordReader (but you can script one, see &lt;A href="https://cwiki.apache.org/confluence/download/attachments/57904847/Provenance_Stream_Record_ReadWrite_1.5.0.xml?version=3&amp;amp;modificationDate=1519670082000&amp;amp;api=v2" target="_blank"&gt;this template&lt;/A&gt; for an example), but however you're using ReplaceText to generate SQL, you could alternatively have it generate JSON or CSV and then configure a &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.5.0/org.apache.nifi.json.JsonTreeReader/index.html" target="_blank"&gt;JsonTreeReader&lt;/A&gt; or &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.5.0/org.apache.nifi.csv.CSVReader/index.html" target="_blank"&gt;CSVReader&lt;/A&gt;. The schema would look like the following (with your field names/types in place of the field1/field2 in the example:&lt;/P&gt;&lt;PRE&gt;{"name": "myRecord", "type": "record", "fields": [
  {"name": "field1", "type": ["null", "int"]},
  {"name": "field2", "type": ["null", "string"]} 
]}&lt;/PRE&gt;&lt;P&gt;For a comprehensive example, see Andrew Lim's &lt;A href="https://community.hortonworks.com/articles/113941/change-data-capture-cdc-with-apache-nifi-version-1-1.html" target="_blank"&gt;CDC with Apache NiFi&lt;/A&gt; series.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 01:09:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226712#M188572</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-03-02T01:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Managing multiple insert queries</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226713#M188573</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;! What a useful solution!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Mar 2018 22:02:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/226713#M188573</guid>
      <dc:creator>basiler82</dc:creator>
      <dc:date>2018-03-02T22:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Managing multiple insert queries</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/291535#M215566</link>
      <description>&lt;P&gt;Is there a way to make this work for inserts in multiple tables?&amp;nbsp; I am looking for a transactional insert to multiple tables, rollback all inserts if insert to one of&amp;nbsp; the tables fail.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 11:14:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/291535#M215566</guid>
      <dc:creator>NitinSonawane</dc:creator>
      <dc:date>2020-03-11T11:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Managing multiple insert queries</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/292413#M216077</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Hello mburgess, &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I am able to extract attributes from using GetFile&amp;gt;SplitXml&amp;gt; EvaluateXQuery processor.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Now, can you please tell me how can I store these dynamic attributes to the PostgreSQL database using PutSQL processor ?&lt;/FONT&gt;&lt;/P&gt;&lt;DIV class="attribute-detail"&gt;&lt;DIV class="attribute-value"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xml_perse_1.JPG" style="width: 687px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/26846i044B5BE2D33D1780/image-size/large?v=v2&amp;amp;px=999" role="button" title="xml_perse_1.JPG" alt="xml_perse_1.JPG" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="attribute-detail"&gt;&lt;DIV class="attribute-value"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xml_perse.JPG" style="width: 683px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/26845i555220C1AF9D5103/image-size/large?v=v2&amp;amp;px=999" role="button" title="xml_perse.JPG" alt="xml_perse.JPG" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class="attribute-value"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="attribute-value"&gt;Is this the correct expression I am putting in PutSQL?&lt;/DIV&gt;&lt;DIV class="attribute-value"&gt;INSERT INTO alstom_radioscopy_amsterdam_blue."xml_log"(block_id,kp_begin,kp_end) VALUES (${block_id.text()},${kp_begin.text()},${kp_end.text()});&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 24 Mar 2020 12:54:26 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Managing-multiple-insert-queries/m-p/292413#M216077</guid>
      <dc:creator>DarkStar</dc:creator>
      <dc:date>2020-03-24T12:54:26Z</dc:date>
    </item>
  </channel>
</rss>

