<?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>topic Re: Insert records into multiple target tables based on Multiple Row counts in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329971#M99108</link>
    <description>&lt;P&gt;Let me know if it helped you, and mark the case as solved if the answer satisfied you (Kudo also accepted).&lt;/P&gt;</description>
    <pubDate>Wed, 06 Sep 2017 22:04:57 GMT</pubDate>
    <dc:creator>TRF</dc:creator>
    <dc:date>2017-09-06T22:04:57Z</dc:date>
    <item>
      <title>Insert records into multiple target tables based on Multiple Row counts</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329968#M99105</link>
      <description>&lt;P&gt;Let’s say I have more than have record in source table and I have 3 destination table A,B,C.&lt;/P&gt; 
&lt;P&gt;I have to insert first 1 to 10 records in A then 11 to 20 in B and 21 to 30 in C.&lt;BR /&gt;Then again from 31 to 40 in A, 41 to 50 in B and 51 to 60 in C… So on up to last record.&lt;/P&gt; 
&lt;P&gt;How to Achieve this?&lt;/P&gt; 
&lt;P&gt;Thanks In Advance.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 14:33:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329968#M99105</guid>
      <dc:creator>Viswa560</dc:creator>
      <dc:date>2017-09-04T14:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Insert records into multiple target tables based on Multiple Row counts</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329969#M99106</link>
      <description>&lt;P&gt;3 output in a tMap with the right expression filter for each should be a solution.&lt;/P&gt;
&lt;P&gt;The expession may be based on a sequence evaluation&amp;nbsp;(see Numeric.sequence).&lt;/P&gt;
&lt;P&gt;There many possibilities to implemente this king of algorithm, for example, have a 1st sequence varying from 1 to 10, each time it arrives to 10, restart to 1 and increment a 2nd sequence (varying from 1 to 3) which is used to decide which output&amp;nbsp;the current record must go to.&lt;/P&gt;
&lt;P&gt;The&amp;nbsp;&lt;SPAN&gt;algorithm can be built using a tJavaRow (so you have tFileInputDelimited -&amp;gt; tJavaRow -&amp;gt; tMap -&amp;gt; tFileOutputDelimited 1, 2 or 3.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 14:47:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329969#M99106</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-09-04T14:47:29Z</dc:date>
    </item>
    <item>
      <title>Re: Insert records into multiple target tables based on Multiple Row counts</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329970#M99107</link>
      <description>&lt;P&gt;To complete my 1st response, here is how it should look like:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 675px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LwRq.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/152527i5F3290E231927767/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LwRq.png" alt="0683p000009LwRq.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;In this example, data comes from tFixedFlowInput and consists of 12 records.&lt;/P&gt; 
&lt;P&gt;The exercise is to dispatch rows on 3 output (like you) for every group of 3 lines (instead of 10).&lt;/P&gt; 
&lt;P&gt;Here is the tJavaRow code:&lt;/P&gt; 
&lt;PRE&gt;if ((Integer)globalMap.get("s2") == null || ((Integer)globalMap.get("s2")) &amp;gt; 2) {
	Numeric.resetSequence("s2", 0);
	if ((Integer)globalMap.get("s1") == null || ((Integer)globalMap.get("s1")) &amp;gt; 2) {
		Numeric.resetSequence("s1", 0);
	}
	globalMap.put("s1", Numeric.sequence("s1", 1, 1));
}
globalMap.put("s2", Numeric.sequence("s2", 1, 1));

output_row.id = input_row.id;
output_row.amount = input_row.amount;
output_row.s1 = (Integer)globalMap.get("s1");
output_row.s2 = (Integer)globalMap.get("s2");&lt;/PRE&gt; 
&lt;P&gt;Fileds s1 and s2 are here only for the demonstration and can be removed.&lt;/P&gt; 
&lt;P&gt;Here is the tMap with the expression filter for each output:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LwQU.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/149674i384B9B40FB4DCE79/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LwQU.png" alt="0683p000009LwQU.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;And the result with 3 distinct groups as expected:&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 541px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LwZE.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/143077i29B18FE5574F0042/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LwZE.png" alt="0683p000009LwZE.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;Hope this helps (don't forget to mark the&amp;nbsp;topic as solved if so - Kudo also accepted).&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 18:59:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329970#M99107</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-09-04T18:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Insert records into multiple target tables based on Multiple Row counts</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329971#M99108</link>
      <description>&lt;P&gt;Let me know if it helped you, and mark the case as solved if the answer satisfied you (Kudo also accepted).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 22:04:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Insert-records-into-multiple-target-tables-based-on-Multiple-Row/m-p/2329971#M99108</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-09-06T22:04:57Z</dc:date>
    </item>
  </channel>
</rss>

