tpostgresOUtput and Auto-increment ID column

One Star

tpostgresOUtput and Auto-increment ID column

Hello,

I can not write in a postgres table which primary key (called dee_id) is auto-incremental.

In Postgres I have a sequence called num_dee_gen and a triggger on the table that calls a stroed procedure :
This procedure get the nextvalue of a sequence and before an insert it sets the new.id to nextval('num_dee_gen'::regclass);


Here is the Stored procedure :
-- Function: dec_dee_insert()
-- DROP FUNCTION dec_dee_insert();
CREATE OR REPLACE FUNCTION dec_dee_insert()
RETURNS trigger AS
$BODY$
begin
--verifie que l'id n'est pas renseigne et si oui donne le bon numero donnee
if new.dee_id is not null then
new.dee_id = nextval('num_dee_gen'::regclass);
--end if;
elsif new.dee_id is null then
new.dee_id = nextval('num_dee_gen'::regclass);
end if;
return new;
end;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION dec_dee_insert() OWNER TO postgres;


in the schema of my tpostgresoutput table I erase the dee_id column.

In the outputPostgresSQL I have written in the advanced settings a column called dee_id, with the SQL statment :
"nextval('\"public\".num_dee_gen')" or "nextval('num_dee_gen'::regclass)"
I've choosen the insert before option and the output column annee.

I got no error in the console but nothing has been inseted in my output table.

How can I get a sequence Nextvalue in postgres with Talend.
I've tried to take the statment of the oracla sequence, but it does not work.
One Star

Re: tpostgresOUtput and Auto-increment ID column

if you could go with a different sequence object for each table id

why not keeping the way you did, but in the additional columns data type use the SERIAL OR BIGSERIAL and then invoquing
"nextval('\"<<SCHEMA_NAME>>\".<<TABLE_NAME>>_<<COLUMN_NAME>>_seq')"
?
it worked for me.

2019 GARTNER 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

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