Showing posts with label talend using database sequence for primary key. Show all posts
Showing posts with label talend using database sequence for primary key. Show all posts

Friday, 22 February 2013

Talend: Using database sequence (postgres sql) to populate primary key or surrogate in target table using talend





Using database sequence (postgres sql) to populate primary key in target table using talend

Problem – we want to use database sequence to generate unique values for primary key column in the target table during insert.

Solution – Talend provides additional columns option in tPostgresqloutput component, which I believe would be similar for all other tdatabaseoutput components.

picture below shows target table dim_page where i have a primary key as page_skey and i want to populate it using dim_page_seq sequence created at database level.
what  we need to do is use additional columns options with sql expression as the function to get next value of sequence from database and position replace.
Also in input to this tPostgresqloutput component i pass page_skey as some dummy value using tmap, which gets overwritten by replace option.

using database sequence




input schema for above output component is as below (this schema is passed as output of tmap)