setting the value of a context variable of type ("list of values"

Highlighted
One Star

setting the value of a context variable of type ("list of values"

using a tjava component, I want to set the values of a context variable of type (list of values) . how can this be done?
Can I use any other type for the context variable that can store a list of values (ex, array ) . and if so , how can I set its values in tjava component
Highlighted
Community Manager

Re: setting the value of a context variable of type ("list of values"

Hello
The type(list of values) is not valiable now, if you want to store records in a list, you can use tJavaFlex component. For example:
tFileInputDelimite---row1--->tJavaFlex
in the begining code, define a a list var:
java.util.List list=new java.util.ArrayList();
in the main code, add records to list:
list.add(row1.coumnName);
in the end code, put the list to a global var:
globalMap.put("list",list);
On other subjob, you can get the list like:
java.util.List list1=(java.util.List)globalMap.get("list");
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Highlighted
One Star

Re: setting the value of a context variable of type ("list of values"

Hi,
My workflow is tMysqlInput -> tflowToIterate -> tJavaflex. For each record in input, I want to test for a particular condition. if it is true, i want to store value of one column in that row in an array. Finally I want to look my array like this : . I want to store this value in context variable and the use in SQL query as "select * from mytable where column1 in"+context.contextVariable1. I tried to use Arraylist as mentioned above and stored it in a context variable of type 'object'. But then it shows error saying that incorrect syntax in sql query and mysql does not know how to access ,,]. This is the format list gets stored in context variable. If I use int array to store these values in javaflex, what should be type of my context variable which would have this value later? Please suggest me some way to accomplish this. I am stuck here for last 2 days! 
Thanks and regards,
Himani
Highlighted
Five Stars

Re: setting the value of a context variable of type ("list of values"

Hey,

Did you resolved this and how?

I have a similar situation where in i need to pass the records (list customer numbers) to the tmap and filter those records if available.

I am trying to figure out 

1> how i can pass the list of customers (from a table) to a variable/context

2>what i need to write in javaflex or any other component to implement it ? 

3>how can i use those passed values all together to filter out ( in tmap or anything )

Highlighted
Four Stars

Re: setting the value of a context variable of type ("list of values"

I thought we can't pass Globalvar to another job, can we?

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog