<?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: Fetch records from a database incrementally based on time interval in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175658#M137915</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;: in incremental case: can we fetch updated rows on next schedule time. like i am adding 3 new rows and update provious row. so can we fetch updated rows also. through timestamp&lt;/P&gt;</description>
    <pubDate>Tue, 23 Oct 2018 11:41:44 GMT</pubDate>
    <dc:creator>niteshchaudhary</dc:creator>
    <dc:date>2018-10-23T11:41:44Z</dc:date>
    <item>
      <title>Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175653#M137910</link>
      <description>&lt;P&gt;Fetch records from a database incrementally based on time interval
We have this requirement to pull records from a database which has millions of records, the only column we can use is a date column. Is there an option to keep incremental based on a time value.
Eg:
 If the initial state is 2018-08-30 12:00:00.00, in the first run it has to fetch the records between 2018-08-30 12:00:00.00 and 2018-08-30 12:15:00.00. Basically it has to keep adding 15 mins after each run. In the next run it has to fetch records between 2018-08-30 12:15:00.00 and 2018-08-30 12:30:00.00.Is this possible to acheive through QueryDatabaseTable processor.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 22:07:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175653#M137910</guid>
      <dc:creator>saravanan_sastr</dc:creator>
      <dc:date>2018-08-30T22:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175654#M137911</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/92267/saravanansastra.html" nodeid="92267" target="_blank"&gt;@Saravanan Subramanian&lt;/A&gt;&lt;P&gt;By using &lt;STRONG&gt;ExecuteSql processor&lt;/STRONG&gt; you can achieve this use case.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;flow:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="87490-flow.png" style="width: 1468px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19772iFDA740A6CD7E4527/image-size/medium?v=v2&amp;amp;px=400" role="button" title="87490-flow.png" alt="87490-flow.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Update attribute configs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="87491-update-attribuite.png" style="width: 2165px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19773iB2A67D4D9EA18B53/image-size/medium?v=v2&amp;amp;px=400" role="button" title="87491-update-attribuite.png" alt="87491-update-attribuite.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;last_iter_val
&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${getStateValue("next_iter_val")} //to get the last iteration value&lt;/PRE&gt;

&lt;/DIV&gt;&lt;P&gt;next_iter_val
&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;${getStateValue("next_iter_val"):toDate("yyyy-MM-dd HH:mm:ss"):toNumber() :plus(900000):format("yyyy-MM-dd HH:mm:ss")} //get the last iteration value and add 15 mins to it&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;ExecuteSql configs:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="87492-es.png" style="width: 2246px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/19774i0C3E8F3960162DD2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="87492-es.png" alt="87492-es.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;By using the attribute values we are going to fetch the records incrementally from the table.&lt;/P&gt;&lt;P&gt;i have attached the xml you can upload that xml and change as per your requirements.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.cloudera.com/legacyfs/online/attachments/87493-hcc-215124.xml" target="_blank"&gt;hcc-215124.xml&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In addition by using same kind of logic you can store your state in DistributeCache/HBase/Hive/HDFS and fetch the state and increment with 15 mins then pull the data from the table.&lt;/P&gt;&lt;P&gt;Refer to &lt;A href="https://community.hortonworks.com/questions/187764/can-executesql-processor-store-state-for-increment.html" target="_blank" rel="nofollow noopener noreferrer"&gt;this&lt;/A&gt; for more details regards to another ways of storing the state in NiFi&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;If the Answer helped to resolve your issue, &lt;STRONG&gt;Click on Accept button below to accept the answer,&lt;/STRONG&gt; That would be great help to Community users to find solution quickly for these kind of issues.&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 10:06:50 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175654#M137911</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2019-08-18T10:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175655#M137912</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;, when we try to import the &lt;A href="https://community.cloudera.com/legacyfs/online/attachments/87493-hcc-215124.xml"&gt;hcc-215124.xml&lt;/A&gt; file we are getting an error as GenerateFlowFile is not known to this Nifi instance. Could you please try to import once to your nifi intance and then share the file again.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 13:23:38 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175655#M137912</guid>
      <dc:creator>saravanan_sastr</dc:creator>
      <dc:date>2018-09-07T13:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175656#M137913</link>
      <description>&lt;P&gt;Hi &lt;A href="https://community.hortonworks.com/users/18929/yaswanthmuppireddy.html"&gt;@Shu&lt;/A&gt;, thanks very much the solution is working. But in case of a failure,we are missing the records.&lt;/P&gt;&lt;P&gt;Eg : Run 1:when executing the query between "2018-09-06 12:00:00.00" and "2018-09-06 12:15:00.00" it is processed successfully&lt;/P&gt;&lt;P&gt;Run 2:In next run the query failed for some reason, "2018-09-06 12:15:00.00" and "2018-09-06 12:30:00.00.&lt;/P&gt;&lt;P&gt;run 3:In subsequent run, Db fetch is successful, "2018-09-06 12:30:00.00" and "2018-09-06 12:45:00.00"&lt;/P&gt;&lt;P&gt;In the above case we are missing the records for Run 2 is there a way to maintain transaction of fully commit or rollback, or combine two processor as a single unit of work?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 20:13:34 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175656#M137913</guid>
      <dc:creator>saravanan_sastr</dc:creator>
      <dc:date>2018-09-07T20:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175657#M137914</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/92267/saravanansastra.html" nodeid="92267"&gt;@Saravanan Subramanian&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For this case please look into &lt;A href="https://community.hortonworks.com/questions/187764/can-executesql-processor-store-state-for-increment.html" target="_blank"&gt;this&lt;/A&gt; link for storing and fetching the state from distributed cache map.&lt;/P&gt;&lt;P&gt;By using this approach we are updating the state only when the pull has been succeeded, if the pull failed then we are not storing the state.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Sep 2018 20:27:14 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175657#M137914</guid>
      <dc:creator>Shu_ashu</dc:creator>
      <dc:date>2018-09-08T20:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175658#M137915</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/18929/yaswanthmuppireddy.html" nodeid="18929"&gt;@Shu&lt;/A&gt;: in incremental case: can we fetch updated rows on next schedule time. like i am adding 3 new rows and update provious row. so can we fetch updated rows also. through timestamp&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 11:41:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175658#M137915</guid>
      <dc:creator>niteshchaudhary</dc:creator>
      <dc:date>2018-10-23T11:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Fetch records from a database incrementally based on time interval</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175659#M137916</link>
      <description>&lt;P&gt;&lt;A href="https://community.hortonworks.com/users/92267/saravanansastra.html"&gt;@&lt;/A&gt;shu: in incremental case: can we fetch updated rows on next schedule time. like i am adding 3 new rows and update provious row. so can we fetch updated rows also. through timestamp &lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2018 12:31:09 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Fetch-records-from-a-database-incrementally-based-on-time/m-p/175659#M137916</guid>
      <dc:creator>niteshchaudhary</dc:creator>
      <dc:date>2018-10-23T12:31:09Z</dc:date>
    </item>
  </channel>
</rss>

