<?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: Last Inserted ID - MSSQL in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361417#M125790</link>
    <description>&lt;P&gt;Thank you. Any idea how to modify the component to use SCOPE_IDENTITY?&lt;/P&gt;</description>
    <pubDate>Thu, 12 Oct 2017 18:15:26 GMT</pubDate>
    <dc:creator>root</dc:creator>
    <dc:date>2017-10-12T18:15:26Z</dc:date>
    <item>
      <title>Last Inserted ID - MSSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361415#M125788</link>
      <description>&lt;P&gt;I have been using tMSSQLLastInsertID to fetch the last inserted id in my table. So far, this method has worked, &amp;nbsp;as most of&amp;nbsp;the data processing was sequential in nature.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Recently, we had some changes and tried inserting data at a quick pace (simulating parallel&amp;nbsp;runs). In that case, the tMSSQLOUTPUT --&amp;gt; tMSSSQLLastInsertID value which was returned is NOT accurate. I&amp;nbsp;just learned that the tMssqlLastInsertID uses "SELECT @@IDENTITY" which may not be the most reliable identifier to use.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have been reading about this on StackOverFlow and people are&amp;nbsp;suggesting "SCOPE_IDENTITY()" or "OUTPUT clause of the INSERT statement".&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Any one has tried these options&amp;nbsp;and can suggest which would be more ideal to use? I really care about the Identity column being returned correctly.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Please advise.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 09:14:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361415#M125788</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2024-11-16T09:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Last Inserted ID - MSSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361416#M125789</link>
      <description>Hi 
&lt;BR /&gt;SCOPE_IDENTITY and @@ IDENTITY are used to retrieve the last identity value generated in any of the tables in the current session, simply by using the global variable of @@ IDENTITY after executing an insert statement to get the ID of the insert record But there is a problem that @@ IDENTITY is global, so it will be reflected in all the scope, an operation, a trigger, a stored procedure called a scope, if there are multiple scopes, the ID number obtained by IDENTITY is the result of the last scope, in this case, we have to use SCOPE_IDENTITY, SCOPE_IDENTITY only returns the values inserted into the current scope; @@ IDENTITY is not limited to a specific scope. 
&lt;BR /&gt;For testing, you can modify the component to use SCOPE_IDENTITY() and verify the result. 
&lt;BR /&gt; 
&lt;BR /&gt;Regards 
&lt;BR /&gt;Shong</description>
      <pubDate>Mon, 09 Oct 2017 07:48:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361416#M125789</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-09T07:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Last Inserted ID - MSSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361417#M125790</link>
      <description>&lt;P&gt;Thank you. Any idea how to modify the component to use SCOPE_IDENTITY?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 18:15:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361417#M125790</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2017-10-12T18:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Last Inserted ID - MSSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361418#M125791</link>
      <description>&lt;P&gt;Hi&lt;BR /&gt;You can follow the below steps to modify the componnet to use SCOPE_IDENTITY:&lt;BR /&gt;&lt;BR /&gt;1. Go to the components' directory&lt;BR /&gt;&amp;lt;studio install dir&amp;gt;\plugins\org.talend.designer.components.localprovider_6.4.0.20170510_1410\components.&lt;BR /&gt;2. Backup the component tMSSqlLastInsertId folder.&lt;BR /&gt;3. Open the tMSSqlLastInsertId folder, edit the tMSSqlLastInsertId_begin.javajet file and modify this line:&lt;BR /&gt;java.sql.PreparedStatement pstmt_&amp;lt;%=cid %&amp;gt; = conn_&amp;lt;%=cid %&amp;gt;.prepareStatement("SELECT @@IDENTITY");&lt;BR /&gt;4. Save the file and restart studio.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Shong&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 08:39:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361418#M125791</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-10-13T08:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: Last Inserted ID - MSSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361419#M125792</link>
      <description>Thank you. I will try that.</description>
      <pubDate>Mon, 16 Oct 2017 15:28:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361419#M125792</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2017-10-16T15:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Last Inserted ID - MSSQL</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361420#M125793</link>
      <description>&lt;P&gt;Another Follow-Up Q&amp;nbsp;&lt;A href="https://community.qlik.com/s/profile/00539000004XsnJAAS"&gt;@shong&lt;/A&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Once I save a&amp;nbsp;fetch a value using the tlastInsertedId, what should be the best method to save it? Should it be a local variable/ context variable/ GlobalMap?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The reason I am asking is in our web service, we sometimes get several requests simultaneously and I have seen some&amp;nbsp;values being over-written.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Please advise. Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 15:31:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Last-Inserted-ID-MSSQL/m-p/2361420#M125793</guid>
      <dc:creator>root</dc:creator>
      <dc:date>2017-10-16T15:31:42Z</dc:date>
    </item>
  </channel>
</rss>

