<?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 in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265916#M45309</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; You are right. Your unique id should be mapped to the target variable where the sequence will be used to generate new unique key. If you have not added this target DB variable in tMap, you will have to add it as an additional variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm Regards,&lt;BR /&gt;Nikhil Thampi&lt;/P&gt;
&lt;P&gt;Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Apr 2019 09:03:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-04-18T09:03:50Z</dc:date>
    <item>
      <title>INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265913#M45306</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt; 
&lt;P&gt;I am new to the forum, so first of all, in case this post is not in the right place, I ask that you move it where appropriate.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="tlid-translation translation"&gt;&lt;SPAN class=""&gt;I am creating a TALEND with API connection, with what is achieved is to make a GET of all available accounts and they are saved in a HASH.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;An Excel file with information is loaded, in a TMap it is checked if those accounts exist or not, in case they exist an INSERT BULK is done in case there is not an UPDATE BULK.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem that I find is when a unique ID to insert arrives.&lt;/SPAN&gt; &lt;SPAN&gt;I need to be able to control in some way that when it is a unique ID I do an INSERT without bulk but I can not find the correct key.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have created a global variable to do the account through Java but it does not work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I attach captures.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 08:19:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265913#M45306</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T08:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265914#M45307</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp; Since you are using an API to extract the data and you are using the hash memory for interim storage, I believe you are playing with low data volume and not in millions of records.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp; So my first suggestion will be to avoid bulk components to avoid complexity in overall flow. Now, coming to the lookup query, I would suggest you to take the maximum value of unique id and then use it as a starting value of a sequence inside your tMap. This will make sure that you are having unique ids during insert without any issues.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;Numeric.sequence("s1",context.max_id,1)&lt;/PRE&gt; 
&lt;P&gt;In this case,&amp;nbsp;context.max_id will have the current max value.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Warm Regards,&lt;BR /&gt;Nikhil Thampi&lt;/P&gt; 
&lt;P&gt;Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 08:51:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265914#M45307</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T08:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265915#M45308</link>
      <description>&lt;P&gt;Thanks for your reply!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not understand very well where I should place that numerical sentence inside the tMap? Create a variable in the tMap and that statement put it as an expression?&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 08:59:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265915#M45308</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T08:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265916#M45309</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; You are right. Your unique id should be mapped to the target variable where the sequence will be used to generate new unique key. If you have not added this target DB variable in tMap, you will have to add it as an additional variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Warm Regards,&lt;BR /&gt;Nikhil Thampi&lt;/P&gt;
&lt;P&gt;Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 09:03:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265916#M45309</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T09:03:50Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265917#M45310</link>
      <description>&lt;P&gt;Thanks Again for your fast reply!&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I created this typology in tMap&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="var1.PNG" style="width: 614px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4ff.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/136789i40FC75B6F924F0DE/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4ff.png" alt="0683p000009M4ff.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;My ID comes from row 18, and the map to the new variable:&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="var2.PNG" style="width: 552px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4fk.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153595i8D8EB90A8C70BADE/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4fk.png" alt="0683p000009M4fk.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I know it is not correct, but I want to make sure that I have understood correctly what you have told me.&lt;/P&gt; 
&lt;P&gt;Is this option as I propose it correct?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 09:18:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265917#M45310</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T09:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265918#M45311</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp;I would do something like below where I will fetch the existing id max value to a context variable as first step.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp;In the second subjob, I will start loading the data with id value starting from current max value+1.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 797px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4VC.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/141161i751D8E5289C2FD2E/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4VC.png" alt="0683p000009M4VC.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The value from DB will be fetched as below.&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 873px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4fu.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133243iAFC253D104D4064B/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4fu.png" alt="0683p000009M4fu.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4Q2.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/148770iCF1D0B366AE4D802/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4Q2.png" alt="0683p000009M4Q2.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Warm Regards,&lt;BR /&gt;Nikhil Thampi&lt;/P&gt; 
&lt;P&gt;Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 09:39:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265918#M45311</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T09:39:19Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265919#M45312</link>
      <description>&lt;P&gt;Thanks for your faster reply!!&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;It is a good solution with what I have stated, really. But I have some doubts that I hope you can guide me in your answer&amp;nbsp; &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;.&lt;/P&gt; 
&lt;P&gt;The first, when consulting an Excel file of input and then go through the tMap if I put there that numeric variable +1 will not work the insert or update that "filter" discriminatory by ID since in the Excel does not come any ID, the ID the I pick up a subquery in the row18 (GET API connection).&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;It had occurred to me to implement what you said but in the INSERT or UPDATE part by means of some type of tFilterRow, that is:&lt;/P&gt; 
&lt;P&gt;Create a counter of ROWs per ID, if the result is &amp;lt;= 2 that makes a BULK if it does not make an INSERT&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="insertbulk.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4fz.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/150023iABC7B25F8A3EF7B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4fz.png" alt="0683p000009M4fz.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tfilterrow.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4Zd.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/158140i15C5EFAD7D97307F/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4Zd.png" alt="0683p000009M4Zd.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;That solution as I could raise it? I have tried with a tFilterRow but it does not work either, I can not think of how I could place that IF.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks again!!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 10:18:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265919#M45312</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T10:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265920#M45313</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp;If my understanding is correct, you are clear about adding the id using sequence for insert records. Your current query is how to separate insert and update records based on input data, right?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp;If you are having the ids from input files itself, then you can separate the data to two flows by checking whether the input id value is null or not. All those records with null id value are candidates for insert and all those records with id value are candidates for update. In the tDBoutput component schema, you need to put a tick mark to the column which will act as key for insert or update.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp; If your scenario is different from above, where you do not have a key from input file, then you will have to do lookup with DB before identifying insert and update records. Join the input dataset with lookup table using inner join and all those records which are failing inner join are candidates for insert (where you can use the sequence from my previous post).&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp;The tMap will look something like below.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4XT.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/152924iAEA66CB4B699DD37/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4XT.png" alt="0683p000009M4XT.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Warm Regards,&lt;BR /&gt;Nikhil Thampi&lt;/P&gt; 
&lt;P&gt;Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 10:38:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265920#M45313</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T10:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: INSERT</title>
      <link>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265921#M45314</link>
      <description>&lt;P&gt;Thanks again!&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I will try to explain a little the talend that I am developing.&lt;/P&gt; 
&lt;P&gt;All the connection I do is via API, so the first thing I do besides request and collect a login token and save it (first line), is to make a call to the DB of the entity to which I want to do the INSERTION or UPDATE.&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="api1.PNG" style="width: 588px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M4g4.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129024iEA73B4EA2CD332E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M4g4.png" alt="0683p000009M4g4.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The second, when receiving the data from an EXCEL file, I opened that file with a tFileInputExcel and using the figure of tHashInput, I mapped all the Excel fields on the one hand and the HashInput retrieved the GET data from the previous image.&lt;/P&gt; 
&lt;P&gt;In the tMap I perform the corresponding mapping of each field with the API field.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;From there, if the ID exists (recovered in the previous subquery) it does an UPDATE if it does not do an INSERT.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If it is INSERT, it goes through a path, creates a JSON and inserts the data through BULK (&amp;lt;1 record)&lt;/P&gt; 
&lt;P&gt;If it is UPDATE it does the same process through bulk.&lt;/P&gt; 
&lt;P&gt;What I try is to control when I only have to insert or update a single record, which can not be a BULK but a simple INSERT or UPDATE.&lt;/P&gt; 
&lt;P&gt;The problem is that I do not know how to perform or what solution is correct, since everything tested does not work for me. &lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MADq.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/146464i525272F95B61C2BD/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MADq.png" alt="0683p000009MADq.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M9p6.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/134116iFBD5D7F21624A744/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M9p6.png" alt="0683p000009M9p6.png" /&gt;&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks for your Help!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Apr 2019 10:51:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/INSERT/m-p/2265921#M45314</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-04-18T10:51:18Z</dc:date>
    </item>
  </channel>
</rss>

