<?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: Auto increment an ID if other ID exists in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329965#M99102</link>
    <description>&lt;P&gt;Refer to the PostgreSQL document but I think you need to select nextval to be able of select currval (that's not what you want).&lt;/P&gt;&lt;P&gt;So you need to select the max value from the table, not the sequence.&lt;/P&gt;&lt;P&gt;All details for solution 3 are included in the link I gave you in the previous post - havec you read id yet?&lt;/P&gt;&lt;P&gt;The better way is to try by yourself.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Nov 2017 13:42:10 GMT</pubDate>
    <dc:creator>TRF</dc:creator>
    <dc:date>2017-11-16T13:42:10Z</dc:date>
    <item>
      <title>Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329956#M99093</link>
      <description>&lt;P&gt;Dear experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to do an auto increment on a field in function of what I receive.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If my couple : &lt;STRONG&gt;car_id &amp;amp; sequence_id already exists&lt;/STRONG&gt;. I would like to &lt;STRONG&gt;increment sequence_id&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ex : I&amp;nbsp;would like to have :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;car_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sequence_id&amp;nbsp;(by auto increment)&lt;/P&gt;&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;3&lt;/P&gt;&lt;P&gt;4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope I am clear.&lt;/P&gt;&lt;P&gt;Thank you for your help. Best regards.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Romain&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 17:07:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329956#M99093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-14T17:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329957#M99094</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;Here it is:&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="0683p000009Lruv.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/149697iAD812A6D13F7A423/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lruv.png" alt="0683p000009Lruv.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;Fields are all declared as Integer.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 17:14:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329957#M99094</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-11-14T17:14:56Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329958#M99095</link>
      <description>&lt;P&gt;Dear TRF,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your answer.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do the same formula as you. It works fine I have :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;car_id&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sequence_id&lt;/P&gt;
&lt;P&gt;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;
&lt;P&gt;2&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;3&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;4&amp;nbsp;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;But, for the &lt;STRONG&gt;2nd run&lt;/STRONG&gt;, when I want to &lt;STRONG&gt;insert&lt;/STRONG&gt; (not update) in my database, I have the error message that I have a &lt;STRONG&gt;duplicate keys&lt;/STRONG&gt; (so the increment doesn't work in this case).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please find copies of my error&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your help.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrIE"&gt;2017-11-16_102928.jpg&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrJ1"&gt;2017-11-16_104133.jpg&lt;/A&gt;</description>
      <pubDate>Thu, 16 Nov 2017 09:42:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329958#M99095</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-16T09:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329959#M99096</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This case wasn't explain in your 1rst post.&lt;/P&gt;&lt;P&gt;3 possibilities:&lt;/P&gt;&lt;P&gt;- store locally (on a file for example) the current sequence value for each car_id and reuse it as a sequence start value for the next run&lt;/P&gt;&lt;P&gt;- get the max sequence_id for each car_id when the job starts&amp;nbsp;&lt;SPAN&gt;and reuse it as a sequence start value&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;- get the&amp;nbsp;&lt;SPAN&gt;max sequence_id for the current car_id using a tMap with lookup to query the db for each input row&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does this helps?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 09:57:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329959#M99096</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-11-16T09:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329960#M99097</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sorry if I wasn't clear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think the 3rd solution is the best in my case.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hum,&amp;nbsp;correct me if I'm wrong&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In tPostgresqlRow,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;select max(sequence_id) from car_temp where source_car_id = database_car_id&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;case&amp;nbsp;max(sequence_id)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; when not null then&amp;nbsp;max(sequence_id) + 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; else&amp;nbsp;max(sequence_id)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;end&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 10:13:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329960#M99097</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-16T10:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329961#M99098</link>
      <description>&lt;PRE&gt;select max(sequence_id) where source_car_id = database_car_id 
case max(sequence_id)
        when not null then max(sequence_id) + 1
        else 1
end&lt;/PRE&gt;&lt;P&gt;change the else clause.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 10:32:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329961#M99098</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-11-16T10:32:08Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329962#M99099</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;My clause doesn't work :&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;UPDATE car_temp SET sequence_id = 
(case (select max(car_staging.sequence) from car_staging,car_temp 
where car_temp.car_id = car_staging.car_id)
       when not null then 
                (select max(car_staging.sequence) from car_staging , car_temp where 
                 car_temp.car_id = car_staging.car_id + 1)
        else (1)
end)&lt;/PRE&gt; 
&lt;P&gt;And I have this error :&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;ERROR: operator does not exist: integer = boolean
SQL state: 42883
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Nov 2017 12:20:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329962#M99099</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-16T12:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329963#M99100</link>
      <description>&lt;P&gt;Don't know what you want to do with that SQL update.&lt;/P&gt;
&lt;P&gt;Read &lt;A href="https://www.talend.com/blog/2017/01/05/talend-job-design-patterns-best-practices-part-4/" target="_self" rel="nofollow noopener noreferrer"&gt;this for an explaination of how to work with lookup in tMap&lt;/A&gt; (search for "&lt;EM&gt;Read at each Row&lt;/EM&gt;" in the page, this is what you need if I understand your case).&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 12:44:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329963#M99100</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-11-16T12:44:53Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329964#M99101</link>
      <description>&lt;P&gt;Ok, I try to do your 3rd method but by sql query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hum so, forget my previous message, can you detail your 2nd and 3rd method please (which component ...)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I get the max(sequence_id) in my source db ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please find my job&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lr1m"&gt;2017-11-16_135239.jpg&lt;/A&gt;</description>
      <pubDate>Thu, 16 Nov 2017 12:53:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329964#M99101</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-16T12:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329965#M99102</link>
      <description>&lt;P&gt;Refer to the PostgreSQL document but I think you need to select nextval to be able of select currval (that's not what you want).&lt;/P&gt;&lt;P&gt;So you need to select the max value from the table, not the sequence.&lt;/P&gt;&lt;P&gt;All details for solution 3 are included in the link I gave you in the previous post - havec you read id yet?&lt;/P&gt;&lt;P&gt;The better way is to try by yourself.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Nov 2017 13:42:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329965#M99102</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-11-16T13:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329966#M99103</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I've succeeded with your link &lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thank you.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Best regards.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2017 14:52:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329966#M99103</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-11-17T14:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Auto increment an ID if other ID exists</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329967#M99104</link>
      <description>Great!</description>
      <pubDate>Sat, 18 Nov 2017 07:53:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Auto-increment-an-ID-if-other-ID-exists/m-p/2329967#M99104</guid>
      <dc:creator>TRF</dc:creator>
      <dc:date>2017-11-18T07:53:00Z</dc:date>
    </item>
  </channel>
</rss>

