Iterative Insert

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 ?


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


All Replies
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

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch