pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Beth Gatewood <beth@vizxlabs.com>
Cc: Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Cc: pgsql-sql@postgresql.org
Subject: Re: writing a function to mimic mysql last_insert_id
Date: Wed, 11 Sep 2002 20:07:16 -0700
Message-ID: <3D8004E4.80004@joeconway.com> (raw)
References: <000f01c25a05$5c549aa0$0c00000a@bethvizx>

Beth Gatewood wrote:
> well, I know that I will have only a single sequence that will generate the
> primary key per table.  So basically, this type of function, for me needs
> only to return the value of the primary key.
> 
> I believe I mentioned in one of my posts the motivation behind not wanting
> to use currval()...which was to trying to avoid having the developers make a
> lot of sql revisions to their application.

Maybe you could use the *same* sequence for the primary key of all the tables, 
say "my_global_seq" (it is bigint as of 7.2 I think), and then wrap a 
last_insert_id() (or whatever it is called) function around a call to 
currval('my_global_seq').

HTH,

Joe







view thread (9+ messages)

Message-ID: <3D8004E4.80004@joeconway.com>
Permalink:  ../3D8004E4.80004@joeconway.com/
Also on:    postgresql.org/message-id/3D8004E4.80004@joeconway.com

 · 

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: mail@joeconway.com, beth@vizxlabs.com, chriskl@familyhealth.com.au
  Subject: Re: writing a function to mimic mysql last_insert_id
  In-Reply-To: <3D8004E4.80004@joeconway.com>

* 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