sorry, now with subject... trigger & nextval(seq) - Mailing list pgsql-sql

From tlange@gwdg.de
Subject sorry, now with subject... trigger & nextval(seq)
Date
Msg-id 45e30277e8954d24114a9fd63720c7e7.squirrel@mailbox.gwdg.de
Whole thread Raw
Responses Re: sorry, now with subject... trigger & nextval(seq)  (Adrian Klaver <adrian.klaver@gmail.com>)
List pgsql-sql
Hello all,

I'm new to triggers in PostgreSQL. I have to create a trigger on insert to
increment a sequence to overcome MS-Access' limitation in acknowledging
serial "datatype".

Could anyone put me on right track? I was looking the whole day for
references on that... Years ago I quickly found a reference how to do it
in Oracle. However, I could not find anything that explained how to do
this in postgresql... I think, it should go the direction see below... But
how exactly :-/ ?


Many thanks for any help, Torsten


create table testtab ( pid bigint, sometext text
);

create sequence test;

-- hmm something like this...?
CREATE FUNCTION count_up (varchar) RETURNS opaque AS ' DECLARE   pid_num bigint; BEGIN   select into pid_num from
selectnextval($);   RETURN pid_num; END;
 
' LANGUAGE 'plpgsql';

-- and how will the trigger looks like
???




pgsql-sql by date:

Previous
From: tlange@gwdg.de
Date:
Subject:
Next
From: Adrian Klaver
Date:
Subject: Re: sorry, now with subject... trigger & nextval(seq)