Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id AF4F4632670 for ; Thu, 20 May 2010 22:36:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 56031-01 for ; Fri, 21 May 2010 01:36:44 +0000 (UTC) X-Greylist: delayed 00:44:19.732352 by SQLgrey-1.7.6 Received: from tmailer.gwdg.de (tmailer.gwdg.de [134.76.10.23]) by mail.postgresql.org (Postfix) with ESMTP id 46F266321D9 for ; Thu, 20 May 2010 22:36:46 -0300 (ADT) Received: from mailer-b1.gwdg.de ([134.76.10.30] helo=mailbox.gwdg.de) by mailer.gwdg.de with esmtp (Exim 4.69) (envelope-from ) id 1OFGTP-0006MH-HM for pgsql-sql@postgresql.org; Fri, 21 May 2010 02:52:23 +0200 X-Xeceived: from 84.132.147.133 (SquirrelMail authenticated user tlange) by mailbox.gwdg.de with HTTP; Fri, 21 May 2010 02:52:23 +0200 Message-ID: Date: Fri, 21 May 2010 02:52:23 +0200 Subject: From: tlange@gwdg.de To: pgsql-sql@postgresql.org User-Agent: SquirrelMail/1.4.20 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: (clean) by exiscan+sophie X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201005/93 X-Sequence-Number: 34141 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 ???