Re: writing a function to mimic mysql last_insert_id - Mailing list pgsql-sql

From Ross J. Reedstrom
Subject Re: writing a function to mimic mysql last_insert_id
Date
Msg-id 20020911173220.GE8991@rice.edu
Whole thread Raw
In response to writing a function to mimic mysql last_insert_id  ("Beth Gatewood" <beth@vizxlabs.com>)
List pgsql-sql
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>



pgsql-sql by date:

Previous
From: Josh Berkus
Date:
Subject: Re: writing a function to mimic mysql last_insert_id
Next
From: "Beth Gatewood"
Date:
Subject: Re: writing a function to mimic mysql last_insert_id