Sunday, 20 October 2013

Talend - Convert string to integer (Integer.parseInt())



Talend - Convert string to integer (Integer.parseInt())

At times you might have a need to convert string to integer in your job. This need could be because of some integer value which you had saved in global variable in talend using globalMap.put() and you need this conversion when you fetch this back using globalMap.get().

One possible way of doing this conversion is as below using java code

String sNum = "10";
int i = Integer.parseInt(sNum);
System.out.println("String value is - "+sNum);
System.out.println("Integer value is - "+i);



Tuesday, 8 October 2013

Talend - ELT DB Components (tELTMysqlInput, tELTMysqlMap,tELTMysqlOutput)


Talend - ELT DB Components (tELTMysqlInput, tELTMysqlMap,tELTMysqlOutput)

Talend provides us some ELT components which are very useful if you want to do a INSERT, UPDATE, DELETE using SQL for example
INSERT INTO target_table
select a.col1, a.col2....
FROM source_table1 a
INNER source_table2 b on (a.col1=b.col1)

These components gives you performance boost for operations where you do not need to bring data to talend server/machine (where job is executing). Using depends on your requirements.

Example -
I have a city and country table in my mysql sakila DB.
I want to join city and country table data and insert into new table country_city using ELT component.

I have to use tELTMysqlInput (for input tables), tELTMysqlOutput (for ouput tables), tELTMysqlMap for join conditions


















tELTMySqlMap - editor where we can specify joins, where/group by conditions
``


Job log after execution - you can see the insert sql in log

[statistics] connecting to socket on port 3572
[statistics] connected
Inserting with :
INSERT INTO country_city(country_id,country,city_id,city) (SELECT country.country_id , country.country , city.city_id , city.city  FROM  country , city WHERE   city.country_id = country.country_id )
--> 600 rows inserted.

[statistics] disconnected
Job jobforblog ended at 05:37 09/10/2013. [exit code=0]