Skip site navigation (1) Skip section navigation (2)

From: tlange(at)gwdg(dot)de
To: pgsql-sql(at)postgresql(dot)org
Date: 2010-05-21 00:52:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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 '
    pid_num bigint;
    select into pid_num from select nextval($);
    RETURN pid_num;
' LANGUAGE 'plpgsql';

-- and how will the trigger looks like


  • Re: at 2010-05-21 01:56:39 from Richard Broersma

pgsql-sql by date

Next:From: tlangeDate: 2010-05-21 00:53:51
Subject: sorry, now with subject... trigger & nextval(seq)
Previous:From: Gary ChambersDate: 2010-05-19 17:16:09
Subject: Re: user function and bind

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group