From: Ross J. Reedstrom <reedstrm@rice.edu>
To: Beth Gatewood <beth@vizxlabs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: writing a function to mimic mysql last_insert_id
Date: Wed, 11 Sep 2002 12:32:20 -0500
Message-ID: <20020911173220.GE8991@rice.edu> (raw)
In-Reply-To: <000701c259b7$f68b3280$0c00000a@bethvizx>
References: <000701c259b7$f68b3280$0c00000a@bethvizx>
Beth -
Take a look at pgsql's sequences. They do pretty much exactly what
you want, here. There's even a 'pseudo type' serial that sets up
an int column with a default value coming from a sequence.
Sequences are more loosely couple to 'auto increment' columns than
in mysql or other database systems. This is sometimes a bit of a pain
(in order to retreive the lsat value, you need to know the name of the
sequence, not just the table.column) but also more powerful: you can set
up columns in several tables that draw from one sequence, for example,
which will guarantee non-colliding values.
Ross
--
Ross Reedstrom, Ph.D. reedstrm@rice.edu
Executive Director phone: 713-348-6166
Gulf Coast Consortium for Bioinformatics fax: 713-348-6182
Rice University MS-39
Houston, TX 77005
On Wed, Sep 11, 2002 at 10:23:35AM -0700, Beth Gatewood wrote:
> Hi all-
>
> I am wondering if I can get some input on the logic that I would need to
> code a function that would mimic mysql's last_insert_id()..
<snip description of mysql's auto increment feature>
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: reedstrm@rice.edu, beth@vizxlabs.com
Subject: Re: writing a function to mimic mysql last_insert_id
In-Reply-To: <20020911173220.GE8991@rice.edu>
* 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