<?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: Postgresql using returning feature in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211814#M9691</link>
    <description>Hi 
&lt;BR /&gt;Take a look at this page on stackoverflow, it introduces several ways to return the last inserted id.
&lt;BR /&gt;
&lt;A href="https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id&lt;/A&gt;
&lt;BR /&gt;
&lt;BR /&gt;After you get the last inserted id, you can store it to a context variable for used later.
&lt;BR /&gt;
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
    <pubDate>Wed, 26 Feb 2020 06:07:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-02-26T06:07:52Z</dc:date>
    <item>
      <title>Postgresql using returning feature</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211813#M9690</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to return the primary key inserted in a table to use this as a foreign key in another table. I know that the command "returning" in postgresql do exactly what I want. Anyone knows how can I do this in Talend Open Studio? I'm trying to use the "returning" because other process will be running at the same time and consuming the same table, so I think that if a use the tDBOutput and after I use the tDBInput to get the last record inserted, maybe I get the record inserted by another process and not the current one. And also, how can I save this data to use at the end of the process?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Scenario:&lt;/P&gt;
&lt;P&gt;I had a table that I will insert a first register in the beginning of the job, and need to use the pk of this record as a foreign key in another table that will be inserted at the end of the job.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 03:11:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211813#M9690</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T03:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: Postgresql using returning feature</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211814#M9691</link>
      <description>Hi 
&lt;BR /&gt;Take a look at this page on stackoverflow, it introduces several ways to return the last inserted id.
&lt;BR /&gt;
&lt;A href="https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id" target="_blank" rel="nofollow noopener noreferrer"&gt;https://stackoverflow.com/questions/2944297/postgresql-function-for-last-inserted-id&lt;/A&gt;
&lt;BR /&gt;
&lt;BR /&gt;After you get the last inserted id, you can store it to a context variable for used later.
&lt;BR /&gt;
&lt;BR /&gt;Regards
&lt;BR /&gt;Shong</description>
      <pubDate>Wed, 26 Feb 2020 06:07:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211814#M9691</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-26T06:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Postgresql using returning feature</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211815#M9692</link>
      <description>&lt;P&gt;Hello&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;Thank for your reply.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;However, what I asked was to how can I perform this in TOS.&lt;/P&gt; 
&lt;P&gt;After a few searches on the community, I founded one component that helped me with this. To help other people, follow bellow what I've done:&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="Dbrow.PNG" style="width: 564px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M9B5.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/139920i745149BB5643D103/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M9B5.png" alt="0683p000009M9B5.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In tDBRow component, I inserted the sql script:&lt;/P&gt; 
&lt;PRE&gt;"INSERT INTO generic VALUES ((SELECT COALESCE(MAX(pk_generic) + 1, 1) FROM generic), 1, 1, 1) RETURNING pk_generic"&lt;/PRE&gt; 
&lt;P&gt;Get the returning statement result with the keyword "RETURNING" and parse this resultset with tParseRecordSet. After that I created a new global var with the value of this resultset.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If exist some other solution for this, please let me know.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Feb 2020 13:59:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Postgresql-using-returning-feature/m-p/2211815#M9692</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-02-26T13:59:12Z</dc:date>
    </item>
  </channel>
</rss>

