<?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: dynamic query from external file in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265669#M45135</link>
    <description>&lt;P&gt;I don't think the flow link column structure can be dynamic. It has to be compiled into the Java.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you could do is construct a query that returns an array of values (if your database has an array data type) in a single column. Or, a key field followed by an array of values that can change based on the config file.&lt;/P&gt;</description>
    <pubDate>Wed, 20 May 2020 17:38:27 GMT</pubDate>
    <dc:creator>PhilHibbs</dc:creator>
    <dc:date>2020-05-20T17:38:27Z</dc:date>
    <item>
      <title>dynamic query from external file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265668#M45134</link>
      <description>&lt;P&gt;Dear Experts,&lt;/P&gt;
&lt;P&gt;Please suggestions needed.&lt;/P&gt;
&lt;P&gt;I have a requirements say, need to create sql query for each columns which is defined in .txt file.&lt;/P&gt;
&lt;P&gt;my .txt file will look like below:&lt;/P&gt;
&lt;P&gt;tbl_name1=tbl1&lt;/P&gt;
&lt;P&gt;cl1=name&lt;/P&gt;
&lt;P&gt;cl2=zipcode&lt;/P&gt;
&lt;P&gt;note: columns is not static may be tomorrow new column can be added.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;now, what i want to do is:&lt;/P&gt;
&lt;P&gt;read the key, value from the file, and store in list may be list..or etc&amp;nbsp;&lt;/P&gt;
&lt;P&gt;get the first column. in this case name&lt;/P&gt;
&lt;P&gt;and, create a sql query ( select name from tbl1)&lt;/P&gt;
&lt;P&gt;next, get the next column, in this case zipcode and create query.......like that need make it dynamic...and if future new columns comes we dont want to edit/change the code, it should form a query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:30:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265668#M45134</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-20T15:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query from external file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265669#M45135</link>
      <description>&lt;P&gt;I don't think the flow link column structure can be dynamic. It has to be compiled into the Java.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you could do is construct a query that returns an array of values (if your database has an array data type) in a single column. Or, a key field followed by an array of values that can change based on the config file.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 17:38:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265669#M45135</guid>
      <dc:creator>PhilHibbs</dc:creator>
      <dc:date>2020-05-20T17:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query from external file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265670#M45136</link>
      <description>&lt;P&gt;is it possible?&lt;/P&gt; 
&lt;P&gt;let say i have something in my text file [c1,c2,c3]&lt;/P&gt; 
&lt;P&gt;convert it as array list&lt;/P&gt; 
&lt;P&gt;count number of items in array list&lt;/P&gt; 
&lt;P&gt;and get the first item from the array list -&amp;gt; create a sql query "select AL[0] from tbl1" &amp;gt; pass to tJavaRow and execute&lt;/P&gt; 
&lt;P&gt;and get the next item from the&amp;nbsp;array list -&amp;gt; create a sql query "select AL[1] from tbl1" &amp;gt; pass to tJavaRow and execute&lt;/P&gt; 
&lt;P&gt;this process do untill the array list end.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 05:07:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265670#M45136</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-05-21T05:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query from external file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265671#M45137</link>
      <description>&lt;P&gt;I would do it by constructing a SQL statement that retrieves an array or structure.&lt;/P&gt; 
&lt;P&gt;If you have this in your file:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;c1,c2,c3&lt;/PRE&gt; 
&lt;P&gt;then for example the query might look like this:&lt;/P&gt; 
&lt;PRE&gt;"SELECT ("+row1.columnlist+") FROM db.tablename"&lt;/PRE&gt; 
&lt;P&gt;In HiveQL, for example, that will return a JSON structure like this:&lt;/P&gt; 
&lt;PRE&gt;{"col1":"0300-819231","col2":"ababc@abc.com","col3":null}&lt;/PRE&gt; 
&lt;P&gt;You could then unpack that JSON using a tExtractJSONFields component.&lt;/P&gt; 
&lt;P&gt;Other databases might vary in their behaviour.&lt;/P&gt; 
&lt;P&gt;Alternatively, this query would return an array:&lt;/P&gt; 
&lt;PRE&gt;"SELECT ARRAY("+row1.columnlist+") FROM db.tablename"&lt;/PRE&gt; 
&lt;P&gt;That would return an array of values rather than a JSON object.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 20:06:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265671#M45137</guid>
      <dc:creator>PhilHibbs</dc:creator>
      <dc:date>2020-05-21T20:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: dynamic query from external file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265672#M45138</link>
      <description>&lt;P&gt;Defending against injection attacks is also a consideration, if you don't absolutely trust the file containing the column list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://xkcd.com/327/" target="_blank" rel="nofollow noopener noreferrer"&gt;https://xkcd.com/327/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 20:14:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/dynamic-query-from-external-file/m-p/2265672#M45138</guid>
      <dc:creator>PhilHibbs</dc:creator>
      <dc:date>2020-05-21T20:14:25Z</dc:date>
    </item>
  </channel>
</rss>

