<?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: Select variable instead of column names in mysql query in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316823#M87337</link>
    <description>&lt;P&gt;Yes, in the 2nd table they are column names ,in the 1st table they are a string inside a cell which i put inside the variable context.Line&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2018 17:23:48 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-01-22T17:23:48Z</dc:date>
    <item>
      <title>Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316819#M87333</link>
      <description>&lt;P&gt;Hello, in tjavarow i have:&lt;/P&gt;&lt;P&gt;String s1=input_row.m_lines;&lt;BR /&gt;int pos=s1.indexOf(":");&lt;/P&gt;&lt;P&gt;context.Line=s1.substring(0,pos) ;&lt;BR /&gt;context.Mask=s1.substring(pos+1) ;&amp;nbsp;&lt;BR /&gt;context.Line holds Name,Surname,Email which are the column names for a 2nd mysql table, in the 2nd mysqlinput im trying to select context.Line instead of the column names like this:&lt;BR /&gt;"SELECT&amp;nbsp; ' "+context.Line+" ' from new_table" but shows me an error and on 'guess schema' got&amp;nbsp;an empty column of string type, can anyone advice me how to call this pls? Thanx&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 16:20:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316819#M87333</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T16:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316820#M87334</link>
      <description>&lt;P&gt;Is context.Line supposed to represent a column name in your query? By the way when writing dynamic SQL like this, do not use guess schema. It will not work very well, if at all&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 16:57:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316820#M87334</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T16:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316821#M87335</link>
      <description>&lt;P&gt;context.Line takes the data from a column named Lines,Lines has in it the values Name,Surname,Email in the cell i took it from based on the row's id from mysql table&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:05:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316821#M87335</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T17:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316822#M87336</link>
      <description>&lt;P&gt;Are&amp;nbsp;&lt;SPAN&gt;Name,Surname,Email column names though? Are you expecting to build a query that says something like....&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SELECT Name From ...?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:18:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316822#M87336</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T17:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316823#M87337</link>
      <description>&lt;P&gt;Yes, in the 2nd table they are column names ,in the 1st table they are a string inside a cell which i put inside the variable context.Line&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:23:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316823#M87337</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T17:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316824#M87338</link>
      <description>&lt;P&gt;OK. You need to remove the single quotes either side of the computed column in your dynamic SQL query. Try that and see what it does.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:27:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316824#M87338</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T17:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316825#M87339</link>
      <description>&lt;P&gt;Still shows me error even when i remove the single quotes&lt;BR /&gt;org.talend.designer.runprocess.ProcessorException: Failed to generate code.&lt;BR /&gt;at org.talend.designer.runprocess.java.JavaProcessor.generateCode(JavaProcessor.java:572)&lt;BR /&gt;at org.talend.designer.runprocess.maven.MavenJavaProcessor.generateCode(MavenJavaProcessor.java:71)&lt;BR /&gt;... 55 more&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:29:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316825#M87339</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T17:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316826#M87340</link>
      <description>&lt;P&gt;Can you give me a screenshot of your job?&lt;/P&gt;&lt;P&gt;Also make sure that your database query component is not in the same subjob as the subjob where you set the context.Line variable. Set that in the subjob before the query is run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Add the following to your existing code and let me know what it prints to the terminal....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;String s1=input_row.m_lines;
int pos=s1.indexOf(":");

context.Line=s1.substring(0,pos) ;
context.Mask=s1.substring(pos+1) ;&amp;nbsp;

String sql = "SELECT&amp;nbsp; &amp;nbsp;"+context.Line+"&amp;nbsp; from new_table";&amp;nbsp;

System.out.println(sql);&lt;/PRE&gt;&lt;P&gt;Try the SQL produced in whatever query analyser you use.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I suspect that your problem is caused by either....&lt;/P&gt;&lt;P&gt;1) Your db component is firing before you have set the context.Line variable (hence, do this in a previous subjob)&lt;/P&gt;&lt;P&gt;2) Your SQL query being produced is poorly formatted SQL&lt;/P&gt;&lt;P&gt;3) Your context.Line variable is not what you think it should be&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 22:38:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316826#M87340</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T22:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316827#M87341</link>
      <description>&lt;P&gt;shows me like this:&lt;/P&gt;&lt;P&gt;[statistics] connected&lt;BR /&gt;SELECT Name from new_table&lt;/P&gt;&lt;P&gt;SELECT Surname from new_table&lt;/P&gt;&lt;P&gt;SELECT Email from new_table&lt;BR /&gt;[statistics] disconnected&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LreQ"&gt;Untitled.png&lt;/A&gt;</description>
      <pubDate>Mon, 22 Jan 2018 23:26:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316827#M87341</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T23:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316828#M87342</link>
      <description>&lt;P&gt;OK, so the queries look OK like that. Do they work for you if you try them in a query analyser?&lt;/P&gt;
&lt;P&gt;If they do, I suspect that this is a timing issue. Can you return the prepared SQL as a column from the tJavaRow? Then connect it to a tFlowToIterate. Then connect that (using an iterate link) to your database component. Then set the SQL query to be the SQL globalMap. If your row connecting the tJavaRow to the tFlowToIterate is called "row12" and your SQL column is called "SQL". Your globalMap can be accessed as ....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;((String)globalMap.get("row12.SQL"))&lt;/PRE&gt;
&lt;P&gt;Put that in your DB component's SQL window (without any quotes, JUST the code above) and it should work.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember, you will need to have a suitable schema configured to return the data.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2018 23:36:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316828#M87342</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-22T23:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316829#M87343</link>
      <description>&lt;P&gt;Thanx a lot for all your help, i did what you told me, placed that select query on the tjava row and linked the tflowtolterate with an iterate link with the mysqlinput of the new_table and it looks like in the attachment:&lt;BR /&gt;shows me this:&lt;BR /&gt;Exception in component tMysqlInput_2 (MD_Main)&lt;BR /&gt;java.sql.SQLException: Can not issue NULL query.&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)&lt;BR /&gt;at com.mysql.jdbc.StatementImpl.checkNullOrEmptyQuery(StatementImpl.java:519)&lt;BR /&gt;at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1481)&lt;BR /&gt;at miliordata.md_main_0_1.MD_Main.tMysqlInput_1Process(MD_Main.java:1390)&lt;BR /&gt;at miliordata.md_main_0_1.MD_Main.runJobInTOS(MD_Main.java:2023)&lt;BR /&gt;at miliordata.md_main_0_1.MD_Main.main(MD_Main.java:1771)&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lre1"&gt;Untitled.png&lt;/A&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:00:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316829#M87343</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316830#M87344</link>
      <description>&lt;P&gt;The row from the tJavaRow to the tFlowToIterate, is it called "row12"? Is the column you've set the SQL query generated in the tJavaRow called "SQL"? Can you take a screenshot of your whole job, your tJavaRow and your tJavaRow schema.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason you are getting the error you are getting is because ((String)globalMap.get("row12.SQL")) is nothing. This is because your key ("row12.SQL") is wrong I believe.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:05:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316830#M87344</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316831#M87345</link>
      <description>&lt;P&gt;Took the screen&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lraf"&gt;Untitled2.png&lt;/A&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:09:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316831#M87345</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316832#M87346</link>
      <description>&lt;P&gt;((String)globalMap.get("row3.SQL")) tried it like this but still error&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:23:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316832#M87346</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:23:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316833#M87347</link>
      <description>&lt;P&gt;I need to see the tJavaRow config, the DB component config, the tFlowToIterate config, the error message, the tJavaRow schema. It is very difficult to identify what is happening without seeing everything.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:30:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316833#M87347</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:30:32Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316834#M87348</link>
      <description>&lt;P&gt;Took them, and the error is this:&lt;BR /&gt;[statistics] connecting to socket on port 3581&lt;BR /&gt;[statistics] connected&lt;BR /&gt;Exception in component tMysqlInput_2 (MD_Main)&lt;BR /&gt;java.sql.SQLException: Can not issue NULL query.&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)&lt;BR /&gt;at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)&lt;BR /&gt;at com.mysql.jdbc.StatementImpl.checkNullOrEmptyQuery(StatementImpl.java:519)&lt;BR /&gt;at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1481)&lt;BR /&gt;at miliordata.md_main_0_1.MD_Main.tMysqlInput_1Process(MD_Main.java:1390)&lt;BR /&gt;at miliordata.md_main_0_1.MD_Main.runJobInTOS(MD_Main.java:2023)&lt;BR /&gt;at miliordata.md_main_0_1.MD_Main.main(MD_Main.java:1771)&lt;BR /&gt;[statistics] disconnected&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrqK"&gt;Untitled1.png&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrqG"&gt;Untitled2.png&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lrc1"&gt;Untitled3.png&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrqU"&gt;Untitled4.png&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009LrqZ"&gt;Untitled5.png&lt;/A&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:42:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316834#M87348</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316835#M87349</link>
      <description>&lt;P&gt;OK, your tJavaRow needs a String column called SQL set up in its schema. Then you need to add this code to bottom of the code that is already there....&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;output_row.SQL = sql;&lt;/PRE&gt;
&lt;P&gt;This will represent the row3.SQL value. At present it is not being supplied since there is no SQL column leaving the tJavaRow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The tFlowToIterate takes row values and converts them to globalMap variables. You didn't have any rows with values leaving the tJavaRow component as nothing was assigned a value. You were setting the context variables, but unfortunately you cannot control the timing of this as rows are not processed one at a time across the whole job. That is why you need to use the tFlowToIterate. This forces the rows to be processed one at a time across the next component.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should at least change your error message. I need to get some sleep now (I'm based in the UK). Give this a go and I will take a look in the morning. I think you are nearly there.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 00:48:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316835#M87349</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T00:48:43Z</dc:date>
    </item>
    <item>
      <title>Re: Select variable instead of column names in mysql query</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316836#M87350</link>
      <description>&lt;P&gt;Works perfectly now, thanx a lot for all your help, you really saved me here ^^ deadline was tomorrow morning in 6 hours&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2018 01:00:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-variable-instead-of-column-names-in-mysql-query/m-p/2316836#M87350</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-01-23T01:00:26Z</dc:date>
    </item>
  </channel>
</rss>

