Showing posts with label Talend Integer.toString(). Show all posts
Showing posts with label Talend Integer.toString(). Show all posts

Thursday, 12 September 2013

Talend: Convert integer to string (primitive type and non primitive type)


Talend: Convert integer to string (primitive type and non primitive type)

One of the most common thing which you would mostly end up needing in your talend job is to convert integer to string. In java this is very simple using inbuild methods but we need to be little aware of data type of integer - whether it is int/integer. Based on datatype the method used is different. however there could be other ways possible to do same.

int i;
i=10;
String str1;
str1=Integer.toString(i);
System.out.println(str1);

Integer i1;
i1 = 20;
str1=i1.toString();
System.out.println(str1);





Friday, 22 February 2013

Talend: Fetch records deleted by tjdbcoutput component (or other database output) in talend and storing it to global variable


Problem -
Fetching number of records deleted/inserted by tjdbcoutput component (or any other tDatabaseoutput comonent) and performing mathematical operation of addition and saving this value to global variable

Solution -
tJDBCOutput_1 - is our output component.
tJDBCOutput_2 - is our another output component.
DEL_ROW_COUNT - is our global variable to store deleted row by above two components

Talend provides NB_Line_Inserted/Deleted/Updated variables for different database output components which we can use after the component has finished.

What we will do is on subJobOk of these components we use java code in tJava component, where we use java functions to get value of these NB_Line* variables and do mathematical operation and store final value to global variable.





Java code is below
globalMap.put("DEL_ROW_COUNT",
Integer.toString((Integer)globalMap.get("tJDBCOutput_1_NB_LINE_DELETED") +
(Integer)globalMap.get("tJDBCOutput_2_NB_LINE_DELETED")));