<?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 tMysqlInput + context variables + IN condition in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307781#M79180</link>
    <description>Hello,&lt;BR /&gt;Trying to use values from a query in a context variable, which is then used within an IN condition in another query. There are a lot of examples using equality conditions which seem to work fine, but when using an IN condition things aren't working as expected. &lt;BR /&gt;&lt;B&gt;SETUP&lt;/B&gt;:&lt;BR /&gt;A string context variable called "excludes" is created and set to a benign value "1" (if value is included in final query it will have no impact). A tMysqlInput_1 component is run and returns:&lt;BR /&gt;1234&lt;BR /&gt;2345&lt;BR /&gt;3456&lt;BR /&gt;which is then piped to tDenormalize which converts it to "1234,2345,3456" and then is set to context.excludes in a tJavaRow. The context values are confirmed by placing the following in the tJavaRow component:&lt;BR /&gt;&lt;PRE&gt;System.out.println(context.exclude);&lt;BR /&gt;context.exclude=input_row.exclude;&lt;BR /&gt;System.out.println(context.exclude);&lt;/PRE&gt;&lt;BR /&gt;When the job runs the values returned are:&lt;BR /&gt;&lt;PRE&gt;1&lt;BR /&gt;1234,2345,3456&lt;/PRE&gt;&lt;BR /&gt;So far so good, we have the correct context values being set up to this point. The next step in the job is to query a different database using tMysqlInput with the following:&lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN ( "+context.excludes+" )&lt;BR /&gt;LIMIT 10&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;B&gt;ISSUE A&lt;/B&gt;: The results returned include rows which should be excluded.&lt;BR /&gt;&lt;B&gt;ISSUE B&lt;/B&gt;: if the context variable is set to something like:&lt;BR /&gt;&lt;PRE&gt;context.exclude="("+input_row.exclude+")";&lt;/PRE&gt;&lt;BR /&gt;and the query is adjusted to:&lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN "+context.excludes+"&lt;BR /&gt;LIMIT 10&lt;/PRE&gt;&lt;BR /&gt;this throws an error in MySQL. &lt;BR /&gt;In the query, fieldA is an INT so not sure how to pass a comma separated list of integers into the query. The query has also been verified by running it in MySQL with the values of the context variable so the query is correct.&lt;BR /&gt;Any help is appreciated as always.</description>
    <pubDate>Tue, 30 Aug 2016 15:33:30 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-08-30T15:33:30Z</dc:date>
    <item>
      <title>tMysqlInput + context variables + IN condition</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307781#M79180</link>
      <description>Hello,&lt;BR /&gt;Trying to use values from a query in a context variable, which is then used within an IN condition in another query. There are a lot of examples using equality conditions which seem to work fine, but when using an IN condition things aren't working as expected. &lt;BR /&gt;&lt;B&gt;SETUP&lt;/B&gt;:&lt;BR /&gt;A string context variable called "excludes" is created and set to a benign value "1" (if value is included in final query it will have no impact). A tMysqlInput_1 component is run and returns:&lt;BR /&gt;1234&lt;BR /&gt;2345&lt;BR /&gt;3456&lt;BR /&gt;which is then piped to tDenormalize which converts it to "1234,2345,3456" and then is set to context.excludes in a tJavaRow. The context values are confirmed by placing the following in the tJavaRow component:&lt;BR /&gt;&lt;PRE&gt;System.out.println(context.exclude);&lt;BR /&gt;context.exclude=input_row.exclude;&lt;BR /&gt;System.out.println(context.exclude);&lt;/PRE&gt;&lt;BR /&gt;When the job runs the values returned are:&lt;BR /&gt;&lt;PRE&gt;1&lt;BR /&gt;1234,2345,3456&lt;/PRE&gt;&lt;BR /&gt;So far so good, we have the correct context values being set up to this point. The next step in the job is to query a different database using tMysqlInput with the following:&lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN ( "+context.excludes+" )&lt;BR /&gt;LIMIT 10&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;B&gt;ISSUE A&lt;/B&gt;: The results returned include rows which should be excluded.&lt;BR /&gt;&lt;B&gt;ISSUE B&lt;/B&gt;: if the context variable is set to something like:&lt;BR /&gt;&lt;PRE&gt;context.exclude="("+input_row.exclude+")";&lt;/PRE&gt;&lt;BR /&gt;and the query is adjusted to:&lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN "+context.excludes+"&lt;BR /&gt;LIMIT 10&lt;/PRE&gt;&lt;BR /&gt;this throws an error in MySQL. &lt;BR /&gt;In the query, fieldA is an INT so not sure how to pass a comma separated list of integers into the query. The query has also been verified by running it in MySQL with the values of the context variable so the query is correct.&lt;BR /&gt;Any help is appreciated as always.</description>
      <pubDate>Tue, 30 Aug 2016 15:33:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307781#M79180</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-30T15:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: tMysqlInput + context variables + IN condition</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307782#M79181</link>
      <description>After some further testing, it would seem that &lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN ( "+context.excludes+" )&lt;BR /&gt;LIMIT 10&lt;/PRE&gt;&lt;BR /&gt;is coming out as&lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN ( '1234,2345,3456' )&lt;BR /&gt;LIMIT 10&lt;/PRE&gt;&lt;BR /&gt;and not&lt;BR /&gt; &lt;BR /&gt;&lt;PRE&gt;SELECT *&lt;BR /&gt;FROM tableA&lt;BR /&gt;WHERE fieldA NOT IN ( 1234,2345,3456 )&lt;BR /&gt;LIMIT 10&lt;/PRE&gt;&lt;BR /&gt;which so far is the only way I can explain how the rows which should be excluded are actually being included.</description>
      <pubDate>Tue, 30 Aug 2016 16:02:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307782#M79181</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-08-30T16:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: tMysqlInput + context variables + IN condition</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307783#M79182</link>
      <description>There is a global variable containing the query string generated by a database input component. &amp;nbsp;Try printing it with a tJava so you can see exactly what's being sent to MySQL.
&lt;BR /&gt;It would be something like ((String)globalMap.get("tMysqlInput_1_QUERY"))</description>
      <pubDate>Tue, 30 Aug 2016 21:38:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tMysqlInput-context-variables-IN-condition/m-p/2307783#M79182</guid>
      <dc:creator>cterenzi</dc:creator>
      <dc:date>2016-08-30T21:38:50Z</dc:date>
    </item>
  </channel>
</rss>

