<?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 Context variable not working as expected in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-not-working-as-expected/m-p/2317194#M87669</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing 2 issues with context variable and need your help to resolve the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Context variable is of string datatype&lt;/P&gt;&lt;P&gt;expression to store the value in context - context.last_run =&amp;nbsp;TalendDate.formatDate("yyyy-MM-dd", input_row.txndate);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.Using below query in tmysqlinput component -&lt;/P&gt;&lt;P&gt;"SELECT MAX(date_format(txndate,'%Y-%m-%d'))&lt;/P&gt;&lt;P&gt;FROM table&lt;/P&gt;&lt;P&gt;where substring(`txndate`,1,10) &amp;gt; '"+context.last_run+"'" -- context datatype is string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;printing in tjava so in console it is coming as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"SELECT MAX(date_format(txndate,'%Y-%m-%d'))&lt;/P&gt;&lt;P&gt;FROM table&lt;/P&gt;&lt;P&gt;where substring(`txndate`,1,10) &amp;gt; '2022-07-29'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issue - if no records present in the table for greater than 2022-07-29 then getting an error as below or job ran for already loaded date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data truncation: Incorrect date value: '' for column 'loaddate' at row 1 (Snapshot attached)&lt;/P&gt;&lt;P&gt;System.out.println("Load Date is before&amp;nbsp;" +&amp;nbsp;input_row.loaddate); &lt;/P&gt;&lt;P&gt;-&amp;gt; getting value as Null on console&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.I am using below query in tmysqlinput component&lt;/P&gt;&lt;P&gt;select col1,col2 from table1 , table2&lt;/P&gt;&lt;P&gt;on table1.no=table2.no&lt;/P&gt;&lt;P&gt;where substring(date_field,1,10)&amp;gt;'"+context.last_run+"'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issue - I am getting past records as well like if I have last run as 2022-07-30 still It is retrieving the past data which is less than 2022-07-30. It should fetch the records greater than 2022-07-30 but it is including 2022-07-29 and 2022-07-30 records as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached the snapshots of the job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Aug 2022 17:44:57 GMT</pubDate>
    <dc:creator>BA621858188</dc:creator>
    <dc:date>2022-08-09T17:44:57Z</dc:date>
    <item>
      <title>Context variable not working as expected</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-variable-not-working-as-expected/m-p/2317194#M87669</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing 2 issues with context variable and need your help to resolve the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Context variable is of string datatype&lt;/P&gt;&lt;P&gt;expression to store the value in context - context.last_run =&amp;nbsp;TalendDate.formatDate("yyyy-MM-dd", input_row.txndate);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.Using below query in tmysqlinput component -&lt;/P&gt;&lt;P&gt;"SELECT MAX(date_format(txndate,'%Y-%m-%d'))&lt;/P&gt;&lt;P&gt;FROM table&lt;/P&gt;&lt;P&gt;where substring(`txndate`,1,10) &amp;gt; '"+context.last_run+"'" -- context datatype is string&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;printing in tjava so in console it is coming as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"SELECT MAX(date_format(txndate,'%Y-%m-%d'))&lt;/P&gt;&lt;P&gt;FROM table&lt;/P&gt;&lt;P&gt;where substring(`txndate`,1,10) &amp;gt; '2022-07-29'"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issue - if no records present in the table for greater than 2022-07-29 then getting an error as below or job ran for already loaded date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data truncation: Incorrect date value: '' for column 'loaddate' at row 1 (Snapshot attached)&lt;/P&gt;&lt;P&gt;System.out.println("Load Date is before&amp;nbsp;" +&amp;nbsp;input_row.loaddate); &lt;/P&gt;&lt;P&gt;-&amp;gt; getting value as Null on console&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.I am using below query in tmysqlinput component&lt;/P&gt;&lt;P&gt;select col1,col2 from table1 , table2&lt;/P&gt;&lt;P&gt;on table1.no=table2.no&lt;/P&gt;&lt;P&gt;where substring(date_field,1,10)&amp;gt;'"+context.last_run+"'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Issue - I am getting past records as well like if I have last run as 2022-07-30 still It is retrieving the past data which is less than 2022-07-30. It should fetch the records greater than 2022-07-30 but it is including 2022-07-29 and 2022-07-30 records as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached the snapshots of the job.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Aug 2022 17:44:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-variable-not-working-as-expected/m-p/2317194#M87669</guid>
      <dc:creator>BA621858188</dc:creator>
      <dc:date>2022-08-09T17:44:57Z</dc:date>
    </item>
  </channel>
</rss>

