<?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 Set context variable from database in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320675#M90791</link>
    <description>&lt;P&gt;I want to pull a max value from a database and use it as the value of a context variable in a job.&amp;nbsp; I've tried things with tJDBCInput and tContextLoad, and threw in some tMap too, but haven't been successful.&amp;nbsp; This seems like a reasonable request that Talend should be able to do, but I can't find any documentation for how to make it happen- just documentation from a delimited file.&amp;nbsp; Thanks for any help you can offer!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Context Variable:&amp;nbsp;context.Process_Max_Section_Date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JDBCInput Query:&lt;/P&gt;&lt;P&gt;"select concat( 'Process_Max_Section_Date=' , max(max_section_date) )&lt;BR /&gt;from repository.public.processing_control_sections&lt;BR /&gt;where completion_date is null&lt;BR /&gt;and ready_to_process_date is not null&lt;BR /&gt;and section = 'SALES'&lt;BR /&gt;;"&lt;/P&gt;</description>
    <pubDate>Thu, 10 May 2018 14:20:45 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-05-10T14:20:45Z</dc:date>
    <item>
      <title>Set context variable from database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320675#M90791</link>
      <description>&lt;P&gt;I want to pull a max value from a database and use it as the value of a context variable in a job.&amp;nbsp; I've tried things with tJDBCInput and tContextLoad, and threw in some tMap too, but haven't been successful.&amp;nbsp; This seems like a reasonable request that Talend should be able to do, but I can't find any documentation for how to make it happen- just documentation from a delimited file.&amp;nbsp; Thanks for any help you can offer!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Context Variable:&amp;nbsp;context.Process_Max_Section_Date&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;JDBCInput Query:&lt;/P&gt;&lt;P&gt;"select concat( 'Process_Max_Section_Date=' , max(max_section_date) )&lt;BR /&gt;from repository.public.processing_control_sections&lt;BR /&gt;where completion_date is null&lt;BR /&gt;and ready_to_process_date is not null&lt;BR /&gt;and section = 'SALES'&lt;BR /&gt;;"&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 14:20:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320675#M90791</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-10T14:20:45Z</dc:date>
    </item>
    <item>
      <title>Re: Set context variable from database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320676#M90792</link>
      <description>Hi,&lt;BR /&gt;You can do one thing -&lt;BR /&gt;1) In JDBCInput use below query -&lt;BR /&gt;select max(max_section_date) AS MaxDate&lt;BR /&gt;from repository.public.processing_control_sections&lt;BR /&gt;where completion_date is null&lt;BR /&gt;and ready_to_process_date is not null&lt;BR /&gt;and section = 'SALES'&lt;BR /&gt;2) Put MaxDate in the schema of tJDBDInput.&lt;BR /&gt;3) After that use tJavaRow and use below code -&lt;BR /&gt;context.MaxDate = input_row.MaxDate&lt;BR /&gt;Don't forget to add this context variable in the context section.&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Abhishek</description>
      <pubDate>Thu, 10 May 2018 14:54:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320676#M90792</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-10T14:54:47Z</dc:date>
    </item>
    <item>
      <title>Re: Set context variable from database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320677#M90793</link>
      <description>&lt;P&gt;Hi Claire,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;You could achieve this by using tJavaRow. I have a job for you to refer.&amp;nbsp;Iam using MySQL.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="job_design.jpg" style="width: 547px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LxXj.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155106iE7621A17E4384B96/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LxXj.jpg" alt="0683p000009LxXj.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have created a context with name 'context_from_DB' , type=date.&lt;/P&gt; 
&lt;P&gt;in My tDBInput i have written a query :&amp;nbsp;"SELECT&amp;nbsp; &amp;nbsp;max(moment) FROM world.stats_table"&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In tJavaRow =&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;System.out.println(row2.moment); Here moment is my column name in tDBInput_1.&lt;BR /&gt;context.context_from_DB=row2.moment;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;and then in my filter i am using this context to filter the records as shown below.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="filter.jpg" style="width: 695px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LwiM.jpg"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/138853i0D94D7FD2ECFB438/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LwiM.jpg" alt="0683p000009LwiM.jpg" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;so I am able to select max value from db and use it in a component.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Hope this helps.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks,&lt;/P&gt; 
&lt;P&gt;RekhaSree&lt;/P&gt;</description>
      <pubDate>Thu, 10 May 2018 16:04:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320677#M90793</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-10T16:04:19Z</dc:date>
    </item>
    <item>
      <title>Re: Set context variable from database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320678#M90794</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;SPAN&gt;Abhishek and&amp;nbsp;RekhaSree,&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN&gt;I'm SO CLOSE, but still getting an error. At the JDBCRow it&amp;nbsp;is returning a syntax error at position 0 for the string that is returned from JDBCInput.&amp;nbsp; Do you have any ideas of what may be off?&amp;nbsp; That error makes me think that component isn't expecting any input.&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN&gt;In the below you'll see date fields that are strings, which is intentional.&amp;nbsp; It's data coming in from a vendor, and has&amp;nbsp;a variety of formats.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Variable1.PNG" style="width: 522px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lxb1.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/145900iCC9702B52649A000/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lxb1.png" alt="0683p000009Lxb1.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Variable2.PNG" style="width: 432px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LxOc.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/134653i52DA5AB10BB095CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LxOc.png" alt="0683p000009LxOc.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;tJDBCInput_1:&amp;nbsp;"select max(max_section_date) as MaxDate&lt;/P&gt; 
&lt;P&gt;from repository.public.PROCESSING_CONTROL_SECTIONS&lt;BR /&gt;where completion_date is null&lt;BR /&gt;and ready_to_process_date is not null&lt;BR /&gt;and section = '"+context.Process_SectionName+ "'&lt;BR /&gt;;"&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Variable3.PNG" style="width: 387px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lxb6.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/133198i172A25A435A51174/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lxb6.png" alt="0683p000009Lxb6.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;tJDBCRow_66:&lt;/P&gt; 
&lt;P&gt;context.Process_Max_Section_Date = row1.MaxDate;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Error on the tJDBCRow_66:&lt;/P&gt; 
&lt;P&gt;Starting job TalJb_Del_Staging_to_Public_Section_Sales at 14:58 11/05/2018.&lt;/P&gt; 
&lt;P&gt;[statistics] connecting to socket on port 3527&lt;BR /&gt;[statistics] connected&lt;BR /&gt;SQL compilation error:&lt;BR /&gt;syntax error line 1 at position 0 unexpected '20180508'.&lt;BR /&gt;[statistics] disconnected&lt;BR /&gt;Job TalJb_Del_Staging_to_Public_Section_Sales ended at 14:58 11/05/2018. [exit code=0]&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 20:28:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320678#M90794</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-11T20:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: Set context variable from database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320679#M90795</link>
      <description>Hi,&lt;BR /&gt;In place of the tjdbcrow, use tJavarow.</description>
      <pubDate>Sat, 12 May 2018 05:25:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320679#M90795</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-12T05:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Set context variable from database</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320680#M90796</link>
      <description>&lt;P&gt;Thank you!!!&amp;nbsp; You totally said that before, and my brain apparently got stuck in the jdbc world.&amp;nbsp; Everything now works &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;&lt;/P&gt;</description>
      <pubDate>Mon, 14 May 2018 14:25:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Set-context-variable-from-database/m-p/2320680#M90796</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-05-14T14:25:47Z</dc:date>
    </item>
  </channel>
</rss>

