<?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: [resolved] Update field values based on Update or insert status in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291357#M64546</link>
    <description>&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;But what I want to know is by using the "Action on data" option of "Update or insert" how can I ensure that I set the created_date value field if the record is going to be "inserted" and set updated_date value if the record is going to be "updated"?&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Hi, 
&lt;BR /&gt;Do you try to just play with "Field options" of the tMySQLOutput :
&lt;BR /&gt;Your tMySQLOutput is design as "Insert or Update" so it will automatically insert or update your output table.
&lt;BR /&gt;In "Fields Options" : 
&lt;BR /&gt;- For your field created_date, check insertable and uncheck updatable ==&amp;gt; So, this field will be populated for an insert and it will not be updated for an update
&lt;BR /&gt;- For your field updated_date, uncheck insertable and check updatable ==&amp;gt; So, this field will not be populated for an insert and will be updated for an update</description>
    <pubDate>Tue, 26 May 2015 15:28:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-05-26T15:28:30Z</dc:date>
    <item>
      <title>[resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291349#M64538</link>
      <description>Hi,
&lt;BR /&gt;This "probably" is not a Talend DI issue but I am not able to figure out how to do it so I am asking here.
&lt;BR /&gt;I have to copy data from 1 database table to another. In the destination table there are 2 fields created_date and updated_date.
&lt;BR /&gt;The value in these fields is to be populated, as the name suggests, when the record is created and updated respectively.
&lt;BR /&gt;So when loading a record from the source into the destination I need to check (based on the destination's primary key) if the record already exists in the destination or not. If it does not then I need to set the value of the created_date field. If the record exists (id is already present) then I need to set the value of the updated_date field and keep the original value of the created_date field.
&lt;BR /&gt;Now my problem is how and where do I make this check and set the appropriate field's value?</description>
      <pubDate>Wed, 13 May 2015 09:37:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291349#M64538</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-13T09:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291350#M64539</link>
      <description>Hi, 
&lt;BR /&gt;What's your target DB? Are you looking for Action on data option " Update or Insert "? 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Sabrina 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MDbW.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/147048i0D0E6A77B916492A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MDbW.png" alt="0683p000009MDbW.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Mon, 18 May 2015 08:16:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291350#M64539</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-18T08:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291351#M64540</link>
      <description>Hi,
&lt;BR /&gt;My target is a Mysql database table.
&lt;BR /&gt;But what I want to know is by using the "Action on data" option of "Update or insert" how can I ensure that I set the created_date value field if the record is going to be "inserted" and set updated_date value if the record is going to be "updated"?</description>
      <pubDate>Mon, 18 May 2015 12:41:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291351#M64540</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-18T12:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291352#M64541</link>
      <description>Do you think that writing a database trigger for this update is an easier option than getting it done through Talend?</description>
      <pubDate>Wed, 20 May 2015 10:55:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291352#M64541</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-20T10:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291353#M64542</link>
      <description>Does nobody have a solution for my problem? Or an opinion whether using database triggers is a better option?</description>
      <pubDate>Tue, 26 May 2015 06:32:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291353#M64542</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-26T06:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291354#M64543</link>
      <description>hi all,
&lt;BR /&gt;use a tMap to inner join on your ID.
&lt;BR /&gt;Use a flow output to update items and another one to create items.
&lt;BR /&gt;your update flow is the output flow where id is found (join).
&lt;BR /&gt;add inner join rejet option for your creates items flow.
&lt;BR /&gt;Use create action for create flow, and update action on table for the other one.
&lt;BR /&gt;Manage update thanks advanced setting and 'use field options'.
&lt;BR /&gt;have a look at talend help for some scenario :
&lt;BR /&gt;
&lt;A href="https://help.talend.com/search/all?query=tMysqlOutput&amp;amp;content-lang=en" rel="nofollow noopener noreferrer"&gt;https://help.talend.com/search/all?query=tMysqlOutput&amp;amp;content-lang=en&lt;/A&gt;
&lt;BR /&gt;
&lt;BR /&gt;hope it helps
&lt;BR /&gt;regards
&lt;BR /&gt;laurent</description>
      <pubDate>Tue, 26 May 2015 10:47:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291354#M64543</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-26T10:47:54Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291355#M64544</link>
      <description>Hi Laurent, 
&lt;BR /&gt;I was able to understand your explanation till the inner join part but then I was lost&amp;nbsp; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MPcz.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157233iD1A564EF62DE3BC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MPcz.png" alt="0683p000009MPcz.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;Do you have some screenshots to help me understand? 
&lt;BR /&gt;I have designed an alternative approach to this where I do the following: 
&lt;BR /&gt; 
&lt;BR /&gt;put the source and destination table as tMysqlInput components 
&lt;BR /&gt;link them to a tMap component with the source as the main link and destination table as lookup 
&lt;BR /&gt;make a left outer join between these tables in the tMap based on the key field 
&lt;BR /&gt;declare a boolean variable "insert_record" and set it's value as (destination_table.key_field == null) 
&lt;BR /&gt;In the output row, to the same destination table as a tMysqlOutput component, I set the value of created_date with the following expression Var.insert_record ? new Date() : destination_table.created_date 
&lt;BR /&gt;Similarly I set the value of updated_date field with the expression !Var.insert_record ? new Date() : null 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MDee.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/142670iCB4F184FCADD50AF/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MDee.png" alt="0683p000009MDee.png" /&gt;&lt;/span&gt;See the above screenshot where I have done the above described mapping. 
&lt;BR /&gt;Do you think this is a good idea? 
&lt;BR /&gt;Also please share your idea with some screenshots (if possible) so that I can try the same.</description>
      <pubDate>Tue, 26 May 2015 12:46:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291355#M64544</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-26T12:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291356#M64545</link>
      <description>could be something like : 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MDTK.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/143562i825BEA41E40FB517/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MDTK.png" alt="0683p000009MDTK.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;the tip is to use "the catch inner join rejet" for the create action. 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MDe6.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/132244iB56F13CE8FEDD1FA/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MDe6.png" alt="0683p000009MDe6.png" /&gt;&lt;/span&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MDej.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154515i8E51F8961D1F5046/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MDej.png" alt="0683p000009MDej.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;regards 
&lt;BR /&gt;laurent</description>
      <pubDate>Tue, 26 May 2015 13:14:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291356#M64545</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-26T13:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291357#M64546</link>
      <description>&lt;BLOCKQUOTE&gt;
 &lt;TABLE border="1"&gt;
  &lt;TBODY&gt;
   &lt;TR&gt;
    &lt;TD&gt;But what I want to know is by using the "Action on data" option of "Update or insert" how can I ensure that I set the created_date value field if the record is going to be "inserted" and set updated_date value if the record is going to be "updated"?&lt;/TD&gt;
   &lt;/TR&gt;
  &lt;/TBODY&gt;
 &lt;/TABLE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;BR /&gt;Hi, 
&lt;BR /&gt;Do you try to just play with "Field options" of the tMySQLOutput :
&lt;BR /&gt;Your tMySQLOutput is design as "Insert or Update" so it will automatically insert or update your output table.
&lt;BR /&gt;In "Fields Options" : 
&lt;BR /&gt;- For your field created_date, check insertable and uncheck updatable ==&amp;gt; So, this field will be populated for an insert and it will not be updated for an update
&lt;BR /&gt;- For your field updated_date, uncheck insertable and check updatable ==&amp;gt; So, this field will not be populated for an insert and will be updated for an update</description>
      <pubDate>Tue, 26 May 2015 15:28:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291357#M64546</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-26T15:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291358#M64547</link>
      <description>for information "Insert or Update" is not a optimize solution (haven't got benchmark result by my side but it 's slower).
&lt;BR /&gt;regards
&lt;BR /&gt;laurent</description>
      <pubDate>Wed, 27 May 2015 08:46:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291358#M64547</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-27T08:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291359#M64548</link>
      <description>Thanks Laurent.&lt;BR /&gt;Your approach seems to work for me.</description>
      <pubDate>Thu, 28 May 2015 11:01:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291359#M64548</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-28T11:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291360#M64549</link>
      <description>thanks to put topic as 'resolved'&lt;BR /&gt;regards&lt;BR /&gt;laurent</description>
      <pubDate>Fri, 29 May 2015 12:52:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291360#M64549</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-29T12:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291361#M64550</link>
      <description>Hi, 
&lt;BR /&gt;I have got one more question related to this. Is there a way to know how many records have been inserted or updated? 
&lt;BR /&gt;A log or a message that can be printed on the console after the job execution is completed.</description>
      <pubDate>Thu, 18 Jun 2015 14:45:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291361#M64550</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-18T14:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291362#M64551</link>
      <description>Yes, you have some variables linked to your tMysqlOutput component : 
&lt;BR /&gt;
&lt;PRE&gt;((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_INSERTED"))&lt;BR /&gt;((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_UPDATED"))&lt;BR /&gt;((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_DELETED"))&lt;BR /&gt;((Integer)globalMap.get("tMysqlOutput_1_NB_LINE_REJECTED"))&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2015 15:21:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291362#M64551</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-18T15:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: [resolved] Update field values based on Update or insert status</title>
      <link>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291363#M64552</link>
      <description>Thanks tangiobs!</description>
      <pubDate>Fri, 19 Jun 2015 05:29:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/resolved-Update-field-values-based-on-Update-or-insert-status/m-p/2291363#M64552</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-19T05:29:06Z</dc:date>
    </item>
  </channel>
</rss>

