• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] foreach variable in a context group?

#1 2009-09-21 18:56:33

Pim
Guest

[resolved] foreach variable in a context group?

Here's my problem that i'm hoping talend could help solve.

So i have a large db and I want to access data from that database using dynamic queries. Lets say I have a db with a column called "colors". I want the user to enter "blue" "red" "brown" and it will query (i.e. select * from somedb WHERE color = "blue" AND color = "red"...) the db and get the results from those three queries. I don't know what colors a user will put in, might be 2, might be 50. Is there a way to put those colors in as context group and do a foreach variable (colors) in a context group, generate a query and get the results from each of those queries. I would appreciate any help on this, thanks!

#2 2009-09-22 05:11:24

shong
Talend team
Registered: 2007-08-29
Posts: 10350
Website

Re: [resolved] foreach variable in a context group?

Hello
You need query records dynamically based on each color entered by user.
Here is java example, please see my screenshots.
tJava_1 code:

Code:

String s=((String)globalMap.get("tMsgBox_1_RESULT"));
             
String [] array=s.split(",");
globalMap.put("array",array);

tMysqlInput_1 query:

Code:

"select * from person where color='"+(String)globalMap.get("color")+"'"

Feel free to ask for help if you have any trouble!

Best regards

          shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2009-09-22 16:42:51

Pim
Guest

Re: [resolved] foreach variable in a context group?

Thanks shong, i'll mess around and see what I can do, if I run into any issues i'll let you know, thanks again.

#4 2009-09-22 21:01:17

Pim
Guest

Re: [resolved] foreach variable in a context group?

This was exactly what I was looking for, got it working perfect, thanks again!

#5 2009-09-22 21:05:44

peterpan
Member
Registered: 2009-09-17
Posts: 11

Re: [resolved] foreach variable in a context group?

Hm.....

I think i can use it as well!!!

Thanks.

Offline

#6 2011-08-05 09:03:35

hiren
Guest

Re: [resolved] foreach variable in a context group?

thnx

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » [resolved] foreach variable in a context group?

Board footer

Powered by FluxBB