auto increment id

One Star

auto increment id

Hi
i want to insert an auto increment id in the target table knowing that this column is not empty
How can i do this
Regards
One Star

Re: auto increment id

Hi
Numeric.sequence("s1",1,1).
stick with: http://www.talendforge.org/forum/viewtopic.php?pid=125052#p125052
Thanks
kumar
Four Stars

Re: auto increment id

Kumar's suggestion will work if you set the initial sequence value first, at the start of every job. Else, it *may* start from 1, which will result in conflicts... If you look at your Talend Routines for Sequence, you will see the method to reset the sequence starting value before using it - then you'll be fine.
Alternatively, if you want to leverage a DB-side sequence for your ID, you can do so easily in the Advanced tab of the Oracle Output component (assuming you're using Oracle).
Four Stars

Re: auto increment id

I always wanted this during the audit data insertion. What I do is
- I set the auto increment for that column at the database side.
- While inserting data i un-check that Id column from talend side (not used)
This way, database will automatically increment the value for that column and data is inserted from talend for that ID during the execution.
If you don't have that option then
- get the max(id) from the database for that column
- Initialize for the sequence and then use the sequence function for that column
Vaibhav
One Star

Re: auto increment id

Hi,
Thank u for your replies,
I'de like to keep my id in may table for updating and deleting rows.
i would like to execute the max(id) but i don't know where to execute the request.
and alse how to get the value in order to be affected to my id
Thank u
Regards
One Star

Re: auto increment id

Hi,
It is always better to Set auto increment in DB level not in Talend level.
Ex: source file have 1000 records,you are inserting into target.
Then auto increment column strat from 1,2....1000.
Next day source file have 500 records,you are inserting in same target table,
Then auto increment column will start from 1001,1002...1500.

Thanks,
kumar