Five Stars

Iterative Insert

Let’s say I have more  than 100  records in my source table and I have 3 destination tables A,B,C. I have to insert first 1 to 10 records in A then 11 to 20 in B and 21 to 30 in C.Then again from 31 to 40 in A, 41 to 50 in B and 51 to 60 in C……So on up to last record. How can i do this in talend ?

1 ACCEPTED SOLUTION

Accepted Solutions
Five Stars

Re: Iterative Insert

Maybe I would do that this way.

 

in a tmap component with a numeric sequence like your other post, I would create three outputs, toTableA, toTableB and toTableC and I would put in each where condition an operation like rownumber div 10, and then the result mod 3, this will give you a number between 0 and 2. If it's 0 then toTableA, if it's 1 toTableB and if its 2 toTableC so you could have in the toTableA output something like that: (rownumber / 10)%3 = 0 , in the toTableB output something like that: (rownumber / 10)%3 = 1 and in the toTableC output something like that: (rownumber / 10)%3 = 2

 

If there's more than 100 rows, then you'd have to div 10 until the result is less than 10

1 REPLY
Five Stars

Re: Iterative Insert

Maybe I would do that this way.

 

in a tmap component with a numeric sequence like your other post, I would create three outputs, toTableA, toTableB and toTableC and I would put in each where condition an operation like rownumber div 10, and then the result mod 3, this will give you a number between 0 and 2. If it's 0 then toTableA, if it's 1 toTableB and if its 2 toTableC so you could have in the toTableA output something like that: (rownumber / 10)%3 = 0 , in the toTableB output something like that: (rownumber / 10)%3 = 1 and in the toTableC output something like that: (rownumber / 10)%3 = 2

 

If there's more than 100 rows, then you'd have to div 10 until the result is less than 10