One Star

[resolved] Joblet and dynamic SQL queries using tFlowToIterate

Hello,
I'm trying to create a Joblet who generate some dynamics queries using a tFlowToIterate, that I try to execute in some DB components.
The following code runs without any problem in a tJava, it returns "Table : pts_dispos"
System.out.print("Table : " + ((String)globalMap.get("enter_flux.table")) + "\n");

But if try to use this same variable in a tMysqlRow, it returns null :
UPDATE cadrage SET libelle = '" + ((String)globalMap.get("enter_flux.table")) + "'

Did someone knows why I get a different result from the same variable in the same emplacement in my process, but in a different component ? The entire process ran without any problems before I refactor it in JobLet.
4 REPLIES
Four Stars

Re: [resolved] Joblet and dynamic SQL queries using tFlowToIterate

In MySQL, try following query
"UPDATE cadrage SET libelle = "+((String)globalMap.get("enter_flux.table"))
Thanks
vaibhav
One Star

Re: [resolved] Joblet and dynamic SQL queries using tFlowToIterate

It returns the following error : "Column 'libelle' cannot be null". So "((String)globalMap.get("enter_flux.table"))" return the null value instead of "pts_dispos", which is still return in the tJava.
One Star

Re: [resolved] Joblet and dynamic SQL queries using tFlowToIterate

I recreate an all new Joblet (see the screenshot) with the following code :

tJava
System.out.print("Valeur : " + ((String)globalMap.get("input.value")) + "\n");

base_xmpie
"SELECT '" + ((String)globalMap.get("input.value")) + "'"

I use this Joblet in a simple job with only a tFixeFlowInput, and this that I had in return :
Démarrage du job Z05_Test_Joblets a 14:16 18/08/2014.
connecting to socket on port 3426
connected
******* 2014-08-18 : 14:16:44 - Z05_Test_Joblets *******
Valeur : value 1
.-----.
|Select value|
|=---=|
|value|
|=---=|
|null |
'-----'
Valeur : value 2
.-----.
|Select value|
|=---=|
|value|
|=---=|
|null |
'-----'
279 milliseconds
disconnected
Job Z05_Test_Joblets terminé à 14:16 18/08/2014.


So it seems to me that tMysql_xxx and tJava doesn't accept the same use in a Joblet.
I use TIS 5.3.1.r104014 on Windows 7.
One Star

Re: [resolved] Joblet and dynamic SQL queries using tFlowToIterate

I resolve my issue with the following solution :
Assign the value of the tFlowToIterate in a new variable via the tJava :
System.out.print("Valeur : " + ((String)globalMap.get("input.value")) + "\n");
globalMap.put("test", ((String)globalMap.get("input.value")));

Using this new variable in the tMysqlInput (and other tMysqlXxxx) :
"SELECT '" + ((String)globalMap.get("test")) + "'"

It gave me a working Joblet :
Valeur : value 1
.-------.
|Select value|
|=-----=|
|value  |
|=-----=|
|value 1|
'-------'
Valeur : value 2
.-------.
|Select value|
|=-----=|
|value  |
|=-----=|
|value 2|
'-------'

It a little more complicated, we have to think to assign all the field, but it works so.