How to create a sequence key for a group of rows?

One Star

How to create a sequence key for a group of rows?

Hi,

I have a file with the details of a Bill of Materials. I need to upload it to a database and generate a line item ID for each row. Each new Bill of Materials has to restart the sequence number. For example,

* File *
bomID | item | quantity
100 | A2EW | 100
100 | H200 | 50
101 | 9028J | 10
101 | A2EW | 200
101 | 9027 | 1
102 | BGHJ | 50

* Table *
bomID | lineID | item | quantity
100 | 1 | A2EW | 100
100 | 2 | H200 | 50
101 | 1 | 9028J | 10
101 | 2 | A2EW | 200
101 | 3 | 9027 | 1
102 | 1 | BGHJ | 50

How do I create the lineID field in order to restart every time the bomID changes?

Thanks,
Alberto

Re: How to create a sequence key for a group of rows?

have you tried using the built-in sequence function?

you can use the bomID as the sequence name and you will get multiple sequences like you want:

in a tMap
lineID = sequence(row1.bomID,1,1);
One Star

Re: How to create a sequence key for a group of rows?

Thanks !!!

I used - per your suggestion - Numeric.sequence(row1.bomID,1,1) on an expression and it worked great !

Thanks a lot,

Alberto

Re: How to create a sequence key for a group of rows?

nope

previous response is rught.

's1'

means sequence name for Talend.
put a tJavaRow, add a column to output as your sequence and 'generate code'
for new column just put previous response

Nicolas
One Star

Re: How to create a sequence key for a group of rows?

I Just want to take bomID and item in place of only bomID and according to that i want to generate the sequence.
* File *
bomID | item      |  quantity
100      | A2EW  |  100
100      | A2EW  |    50
101      | 9028J  |    10 
101      | A2EW  |  200
101      | 9027    |      1
102      | BGHJ  |    50

* Table *
bomID | lineID   | item      |  quantity
100      |          1 | A2EW  |  100
100      |          2 | A2EW   |    50
101      |          1 | 9028J  |    10 
101      |          1 | A2EW  |  200
101      |          1 | 9027    |      1
102      |          1 | BGHJ  |    50


Please help me..

Mano

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

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog