<?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: Look up to get max id in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201801#M3752</link>
    <description>&lt;P&gt;Many many thanks, JR. The job ran fine. The data looks good as expected.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Aug 2019 20:36:30 GMT</pubDate>
    <dc:creator>A_San</dc:creator>
    <dc:date>2019-08-22T20:36:30Z</dc:date>
    <item>
      <title>Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201784#M3735</link>
      <description>&lt;P&gt;New to talend. I am trying to load a table say stg0 from a source file. one of the columns in target is batch_id. For every run, the batch id should increment by 1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For ex: If I load file 1 and later file 2, the batch id should be 1 for file 1 and 2 for file 2. So I should look up on the STG0 table and get the max batch id and increment by 1. I am trying to use tmap to achieve this. My main connection to tmap is the source delimited file and look up table is STG 0. In tmap, I cannot join between source file and stg0. I am not sure how to go about this. Any help would be appreciated.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:55:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201784#M3735</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2024-11-16T04:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201785#M3736</link>
      <description>One way I can think (if I understand your question well 
&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; ), is: 
&lt;BR /&gt;Read the stg0 table and find the max batch_id and save it in a context/ globalMap variable. 
&lt;BR /&gt; 
&lt;BR /&gt;Then, load the file and connect it to target via tMap. 
&lt;BR /&gt; 
&lt;BR /&gt;In the tMap, where the target batchid is present, set the value as the context/ globalMap variable + 1 
&lt;BR /&gt; 
&lt;BR /&gt;HTH.</description>
      <pubDate>Mon, 19 Aug 2019 20:00:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201785#M3736</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2019-08-19T20:00:22Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201786#M3737</link>
      <description>&lt;P&gt;Do you mean to say not to have a look up?&lt;/P&gt;&lt;P&gt;I can try that. Could you please let me know how I can&amp;nbsp;&lt;SPAN&gt;save it in a context/ globalMap variable ? Should this be done in Tmap?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:00:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201786#M3737</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-19T21:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201787#M3738</link>
      <description>&lt;P&gt;This is what I have currently. Please see screenshot of my job&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LvwX"&gt;SS1.PNG&lt;/A&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:04:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201787#M3738</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-19T21:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201788#M3739</link>
      <description>I would have tDBInput --&amp;gt; tJavaRow where I capture the output of the query. Then, assign that value to context/ globalMap:
&lt;BR /&gt;
&lt;BR /&gt;lets say you have the query as: select max(id_batch_id) as 'current_max_batch_id' from stg_0_id_cntl_nmc;
&lt;BR /&gt;Keep this id as Int in the schema
&lt;BR /&gt;
&lt;BR /&gt;// in tJavaRow
&lt;BR /&gt;// setting context
&lt;BR /&gt;context.current_max_batch_id = input_row.curr_batch_id
&lt;BR /&gt;OR
&lt;BR /&gt;// setting via GlobalMap
&lt;BR /&gt;globalMap.put("curr_batch_id" = input_row.curr_batch_id;
&lt;BR /&gt;
&lt;BR /&gt;Then, on subjob ok, you can do the file list --&amp;gt; fileinputdelimited --&amp;gt; tMap --&amp;gt; tDB Output
&lt;BR /&gt;
&lt;BR /&gt;in tMap, for the target field of batch_id, you can use the expression
&lt;BR /&gt;// if context:
&lt;BR /&gt;context.current_max_batch_id +1
&lt;BR /&gt;or
&lt;BR /&gt;// (int)globalMap.get("current_max_batch_id") + 1;
&lt;BR /&gt;// (Integer)
&lt;BR /&gt;
&lt;BR /&gt;HTH.</description>
      <pubDate>Mon, 19 Aug 2019 21:19:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201788#M3739</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2019-08-19T21:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201789#M3740</link>
      <description>&lt;P&gt;Or without custom coding using tJavaRow, you could have your tDBInput component's output (column name "count") end in a tSetGlobalVar and set the value to row1.count (replace row1 with the name of your connector). You could then use this variable in your tMap (without any lookup) and raise it by one using&lt;/P&gt;
&lt;PRE&gt;((Integer)globalMap.get("count")) + 1&lt;/PRE&gt;
&lt;P&gt;as an output expression. If you can solve something without custom code components, you should do so.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 21:35:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201789#M3740</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2019-08-19T21:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201790#M3741</link>
      <description>&lt;P&gt;I am getting this error in tJavaRow.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error in the component's properties:current_max_batch_id cannot be resolved or is not a field&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also how do I link tJavaRow to the main flow which is&amp;nbsp;&lt;SPAN&gt;file list --&amp;gt; fileinputdelimited --&amp;gt; tMap --&amp;gt; tDB Output&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 22:06:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201790#M3741</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-19T22:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201791#M3742</link>
      <description>&lt;P&gt;I am not sure I follow this -&amp;nbsp;&lt;SPAN&gt;tDBInput component's output (column name "count") end in a tSetGlobalVar and set the value to row1.count (replace row1 with the name of your connector). Could you please explain? I am very new to Talend.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tSetGlobalVar is also a custom code, isnt it?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2019 22:08:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201791#M3742</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-19T22:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201792#M3743</link>
      <description>&lt;P&gt;OK. Looking at your job, I have an additional question. Do you want the number to increase withing the job, i.e. for each file you are loading in this one job, or do you want this to increase between job runs as well, i.e. yesterday this job ran and in the end the number was 164 and today it should start with 165?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 07:04:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201792#M3743</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2019-08-20T07:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201793#M3744</link>
      <description>&lt;P&gt;Batch Id should increase between job runs. I have another column file_id.&lt;/P&gt;&lt;P&gt;When I run the job today, the batch id will be say 1 and if there are 2 files to be loaded in this batch, then the file id will be 1 and 2 for the respective files.&lt;/P&gt;&lt;P&gt;Next time when I run the job, the batch id will be 2 and the file id will be reset to 1 and depending on the no. of files, it will be incremented by 1.&lt;/P&gt;&lt;P&gt;Please see attached screenshot for example.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lw8T"&gt;SS2.PNG&lt;/A&gt;</description>
      <pubDate>Tue, 20 Aug 2019 15:15:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201793#M3744</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-20T15:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201794#M3745</link>
      <description>&lt;P&gt;OK, here we go.&lt;/P&gt; 
&lt;P&gt;I have recreated the job as a rudimentary structure. In a first step, you create a tDBInput and put in the "max" statement. The schema of this component must just be "count" of type "Integer" (feel free to chose a different column name). If your table contains a lot of records, executing this query may take a while - use the usual query optimisation techniques like indexes in this case (outside this job).&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.jpg" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M6mC.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157164iDA7F08A4A7A04BA9/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M6mC.jpg" alt="0683p000009M6mC.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Then you store this max value in a global variable using tSetGlobalVar (increased by one). Name it "count" or whatever.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.jpg" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M6mD.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/156136i4C5DC7586364C078/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M6mD.jpg" alt="0683p000009M6mD.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Then you can use this global variable in your tMap (tMap_1 in the picturre above) and all the records will get the same value for "batch" (which is what you want)&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.jpg" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M72y.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/151850i62ABCA48161F9C2C/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M72y.jpg" alt="0683p000009M72y.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Let us know, if this solves your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2019 18:44:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201794#M3745</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2019-08-20T18:44:15Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201795#M3746</link>
      <description>&lt;P&gt;JR,&lt;/P&gt;&lt;P&gt;I did as you said. Not sure if I missed something. I am getting some errors. Please see screenshot.&lt;/P&gt;&lt;P&gt;Appreciate all your help.&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lvk2"&gt;SS4.PNG&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lw97"&gt;SS3.PNG&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LwNc"&gt;SS5.PNG&lt;/A&gt;</description>
      <pubDate>Thu, 22 Aug 2019 17:47:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201795#M3746</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-22T17:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201796#M3747</link>
      <description>&lt;P&gt;Yes, you missed something. It is "Count" which needs to have double quotes around it and row1.count + 1 must not have them.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:24:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201796#M3747</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2019-08-22T18:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201797#M3748</link>
      <description>&lt;P&gt;Thank you JR.&lt;/P&gt;
&lt;P&gt;Could you also please let me know why I am getting "Type mismatch: cannot convert from char to String" error in tMap?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:44:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201797#M3748</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-22T18:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201798#M3749</link>
      <description>&lt;P&gt;Sorry, I missed that. Sure: change the 'S' to "S" for column Id_stus. Single characters in single quotes are treated as Char in Java, whereas double quotes define a String. Basically, you tell Talend to put a Char value ('S') into a String column.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 19:23:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201798#M3749</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2019-08-22T19:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201799#M3750</link>
      <description>&lt;P&gt;I am gettting this error now. Reason could the table is empty. How and Where do I say that if max(batch_id) is null, then count should be 1 to start with?&lt;/P&gt;&lt;P&gt;Exception in component tSetGlobalVar_1 (STG_0_LD_CNTL_NMCP)&lt;BR /&gt;java.lang.NullPointerException&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 20:01:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201799#M3750</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-22T20:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201800#M3751</link>
      <description>&lt;P&gt;How about modifying your SQL statement so that it always returns at least 1. If you are using PostgreSQL, you could try with the following (not a PostgreSQL expert):&lt;/P&gt; 
&lt;PRE&gt;SELECT COALESCE(MAX(batch_id), 1) FROM XXXX&lt;/PRE&gt; 
&lt;P&gt;COALESCE always returns the first value of the parameters that is not null.&lt;/P&gt; 
&lt;P&gt;If this does not work, you could put a tMap after the "count" tDBInput and set the value to 1 by using the following expression&lt;/P&gt; 
&lt;PRE&gt;row1.count == null ? 1 : row1.count&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 20:18:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201800#M3751</guid>
      <dc:creator>JR1</dc:creator>
      <dc:date>2019-08-22T20:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Look up to get max id</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201801#M3752</link>
      <description>&lt;P&gt;Many many thanks, JR. The job ran fine. The data looks good as expected.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 20:36:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Look-up-to-get-max-id/m-p/2201801#M3752</guid>
      <dc:creator>A_San</dc:creator>
      <dc:date>2019-08-22T20:36:30Z</dc:date>
    </item>
  </channel>
</rss>

