Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Select variable instead of column names in mysql query

Hello, in tjavarow i have:

String s1=input_row.m_lines;
int pos=s1.indexOf(":");

context.Line=s1.substring(0,pos) ;
context.Mask=s1.substring(pos+1) ; 
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:
"SELECT  ' "+context.Line+" ' from new_table" but shows me an error and on 'guess schema' got an empty column of string type, can anyone advice me how to call this pls? Thanx

Labels (3)
17 Replies
Anonymous
Not applicable
Author

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:
shows me this:
Exception in component tMysqlInput_2 (MD_Main)
java.sql.SQLException: Can not issue NULL query.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)
at com.mysql.jdbc.StatementImpl.checkNullOrEmptyQuery(StatementImpl.java:519)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1481)
at miliordata.md_main_0_1.MD_Main.tMysqlInput_1Process(MD_Main.java:1390)
at miliordata.md_main_0_1.MD_Main.runJobInTOS(MD_Main.java:2023)
at miliordata.md_main_0_1.MD_Main.main(MD_Main.java:1771)


Untitled.png
Anonymous
Not applicable
Author

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. 

 

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.

Anonymous
Not applicable
Author

Took the screen


Untitled2.png
Anonymous
Not applicable
Author

((String)globalMap.get("row3.SQL")) tried it like this but still error

Anonymous
Not applicable
Author

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. 

Anonymous
Not applicable
Author

Took them, and the error is this:
[statistics] connecting to socket on port 3581
[statistics] connected
Exception in component tMysqlInput_2 (MD_Main)
java.sql.SQLException: Can not issue NULL query.
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1084)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:973)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)
at com.mysql.jdbc.StatementImpl.checkNullOrEmptyQuery(StatementImpl.java:519)
at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1481)
at miliordata.md_main_0_1.MD_Main.tMysqlInput_1Process(MD_Main.java:1390)
at miliordata.md_main_0_1.MD_Main.runJobInTOS(MD_Main.java:2023)
at miliordata.md_main_0_1.MD_Main.main(MD_Main.java:1771)
[statistics] disconnected


Untitled1.png
Untitled2.png
Untitled3.png
Untitled4.png
Untitled5.png
Anonymous
Not applicable
Author

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....

 

output_row.SQL = sql;

This will represent the row3.SQL value. At present it is not being supplied since there is no SQL column leaving the tJavaRow.

 

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. 

 

 

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.

Anonymous
Not applicable
Author

Works perfectly now, thanx a lot for all your help, you really saved me here ^^ deadline was tomorrow morning in 6 hours