Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
stephbzr
Contributor III
Contributor III

Store the values of a SQL query in a global variable

Hello, 

I am looking to do something for the first time in Talend. I need to store the results of a SQL query in several global variables. Let me explain. The query below returns 4 values positioned in line in Oracle. In Talend, I would obviously have the same result. What I want to do is store each value in a global variable, but it's difficult to do that knowing that they are returned in a column.

 

0695b00000fJyTyAAK.png 

0695b00000fJyU3AAK.png 

I'm thinking that maybe I need to create a different SQL query to get the 4 rows in 4 columns, but I don't see how at the moment. But I wonder if there is a Talend component that can convert 4 rows into 4 columns, which I think can help me.

Do you have an idea? I am thinking of creating the global variables using a tFlowToIterate or tSetGlobalVar, I don't know which is better.

Labels (5)
4 Replies
Anonymous
Not applicable

Hi

I don't understand what's the purpose of storing the value into global variables, however, if you want to have the output like this

c1;c2;c3;c4

484287;4044301;1

 

You can use tDenormalize+tExtractDelimitedFields to achieve it after reading these 4 rows from DB.

 

Regards

Shong

 

stephbzr
Contributor III
Contributor III
Author

Hello @Shicong Hong​ ,

 

Thanks, I will try your solution. I need to store these 4 values in a global variable for each because they are input parameters I need for a procedure (tDBSP). The reason why I need to get them this way. 

Anonymous
Not applicable

Yes, after you convert rows to columns, you can store the each value to different global variables on tJavaRow for used later, but you just want to pass these value to tDBSP as input parameters, passing directly them from tExtractDelimitedFields to tDBSP without global variables, you can select the columns on tDBSP.

 

 

AChardon
Contributor
Contributor

You could try that too, allow to call Global var by their name.

0695b00000fKexHAAS.png0695b00000fKexbAAC.pngflowinput is here to simulate the db component, use newcolumn1 and newcolumn as colum name.