pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: tlange@gwdg.de
To: pgsql-sql@postgresql.org
Subject: sorry, now with subject... trigger & nextval(seq)
Date: Fri, 21 May 2010 02:53:51 +0200
Message-ID: <45e30277e8954d24114a9fd63720c7e7.squirrel@mailbox.gwdg.de> (raw)

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 select nextval($);
    RETURN pid_num;
  END;
' LANGUAGE 'plpgsql';

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





view thread (4+ messages)  latest in thread

Message-ID: <45e30277e8954d24114a9fd63720c7e7.squirrel@mailbox.gwdg.de>
Permalink:  ../45e30277e8954d24114a9fd63720c7e7.squirrel@mailbox.gwdg.de/
Also on:    postgresql.org/message-id/45e30277e8954d24114a9fd63720c7e7.squirrel@mailbox.gwdg.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tlange@gwdg.de
  Subject: Re: sorry, now with subject... trigger & nextval(seq)
  In-Reply-To: <45e30277e8954d24114a9fd63720c7e7.squirrel@mailbox.gwdg.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox