Re: writing a function to mimic mysql last_insert_id

From: "Ross J(dot) Reedstrom" <reedstrm(at)rice(dot)edu>
To: Beth Gatewood <beth(at)vizxlabs(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: writing a function to mimic mysql last_insert_id
Date: 2002-09-11 17:32:20
Message-ID: 20020911173220.GE8991@rice.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rice(dot)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>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Beth Gatewood 2002-09-11 17:43:42 Re: writing a function to mimic mysql last_insert_id
Previous Message Josh Berkus 2002-09-11 17:30:46 Re: writing a function to mimic mysql last_insert_id