Get value after every n counts

Seven Stars

Get value after every n counts

Hi,

 

I get the max(ID) from the table which is BigDecimal(7,0). This value I am passing to tJavaRow component to assign the value to globalMap as below:
globalMap.put("startID", "1");
globalMap.put("endID", String.valueOf(row1.maxID));
globalMap.put("rowsToProcess", "40000000" );

OnComponentOK, connecting to tLoop component where the For loop is chosen as below:

From - 1

To - Integer.parseInt(globalMap.get("endID").toString())

Step - Integer.parseInt(globalMap.get("rowsToProcess").toString())

 

This raises NumberFormatException. 

java.lang.NumberFormatException: For input string: "4979013401".

 

Is there any other way to generate value from start id to end id every n'th value.

 

Thanks.


Accepted Solutions
Sixteen Stars TRF
Sixteen Stars

Re: Get value after every n counts

Max value for an integer is 2,147,483,647...


TRF

View solution in original post

Eleven Stars

Re: Get value after every n counts

4979013401 is higher than above maximum possible value for Int 

 

Instead try Long but you have to use While Loop instead of For( doesnot support Long)

 

start condition

 

 Long i = 0L

 

Regards
Abhishek KUMAR

View solution in original post


All Replies
Sixteen Stars TRF
Sixteen Stars

Re: Get value after every n counts

Max value for an integer is 2,147,483,647...


TRF

View solution in original post

Eleven Stars

Re: Get value after every n counts

4979013401 is higher than above maximum possible value for Int 

 

Instead try Long but you have to use While Loop instead of For( doesnot support Long)

 

start condition

 

 Long i = 0L

 

Regards
Abhishek KUMAR

View solution in original post

Seven Stars

Re: Get value after every n counts

Hi TRF,

 

System.out.println((Long)globalMap.get("tLoop_1_CURRENT_VALUE")); is returning NULL in tJava component.

 

How do I get the tLoop value ?

 

Thanks.

Seven Stars

Re: Get value after every n counts

Hi,

 

System.out.println((Long)globalMap.get("tLoop_1_CURRENT_VALUE")); is returning NULL in tJava component.

 

How do I get the tLoop value ?

 

Thanks.

Seven Stars

Re: Get value after every n counts

Hi,

 


System.out.println((Long)globalMap.get("tLoop_1_CURRENT_ITERATION"));

 

globalMap.get("tLoop_1_CURRENT_ITERATION") is by default Integer. 

int current_iteration_tLoop_1 = 0;

 

How would it transfer Long value?

 

Is there any other way to achieve this?

 

Thanks.

 

Eleven Stars

Re: Get value after every n counts

Hmm , If you need to use counter value in long
Immediately after tloop put a tjava and create a your own long globalmap
counter and use that custom value in your subjob
Regards
Abhishek KUMAR

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch 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