How to use java var on SQL query ?

Seven Stars

How to use java var on SQL query ?

Hello,  I have on my tXMLMap,some values , and with this values, I would like to make a sql query to get the id on the table and insert this id to an another SQL query .

First, I used tSetGlobalVar, but in my sql query ( Oracle Row) it doing nothing.

My query is like

"SELECT max(my_table_name) as table_id FROM table WHERE  table.name =' " + id  + "' 

ID was the name of my SetGlobalVar , I use

StringHandling.UPCASE(row2.USERNAME) 

for the Value

 

 

How can I use the query and insert into the tOracleOutput ? tos.PNG


Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: How to use java var on SQL query ?

You can connect your tOracle(or other DB)Input component to a tSetGlobalVar to get the result into a new global variable.

Then, or you use a tOracleRow and you introduce the query by yourself (using the preceding global variable).

You map also use a standard tOracleOutput component for which the desired field will be populated with the global variable content (probably in a tMap or tJavaRow).

 

Thank's to mark your case as solved and open a new one for new or derived questions.


TRF

All Replies
Forteen Stars TRF
Forteen Stars

Re: How to use java var on SQL query ?

Hi,

If you have a global variable called "id" you have to change your query like this one:

"SELECT max(my_table_name) as table_id FROM table WHERE  table.name = '" + (String)globalMap.get("id")  + "'"

Hope this helps.

 


TRF
Seven Stars

Re: How to use java var on SQL query ?

Hello, and thanks for the solution, its working, but now, I want to get this result of my query and add to the other query  Its be like

Insert into my_table (table1,table2table3) 
Values("Her the result of my first query","test",1)
Forteen Stars TRF
Forteen Stars

Re: How to use java var on SQL query ?

You can connect your tOracle(or other DB)Input component to a tSetGlobalVar to get the result into a new global variable.

Then, or you use a tOracleRow and you introduce the query by yourself (using the preceding global variable).

You map also use a standard tOracleOutput component for which the desired field will be populated with the global variable content (probably in a tMap or tJavaRow).

 

Thank's to mark your case as solved and open a new one for new or derived questions.


TRF