Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D91B3476B02 for ; Wed, 11 Sep 2002 13:32:22 -0400 (EDT) Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (Postfix) with ESMTP id E5F28476B12 for ; Wed, 11 Sep 2002 13:32:21 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id 9029068A66; Wed, 11 Sep 2002 12:32:21 -0500 (CDT) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id D06F568A65; Wed, 11 Sep 2002 12:32:20 -0500 (CDT) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.34 #1 (Debian)) id 17pBLg-0002Vk-00; Wed, 11 Sep 2002 12:32:20 -0500 Date: Wed, 11 Sep 2002 12:32:20 -0500 From: "Ross J. Reedstrom" To: Beth Gatewood Cc: pgsql-sql@postgresql.org Subject: Re: writing a function to mimic mysql last_insert_id Message-ID: <20020911173220.GE8991@rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , Beth Gatewood , pgsql-sql@postgresql.org References: <000701c259b7$f68b3280$0c00000a@bethvizx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000701c259b7$f68b3280$0c00000a@bethvizx> User-Agent: Mutt/1.3.27i X-Virus-Scanned: by AMaViS snapshot-20020300 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/82 X-Sequence-Number: 9359 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()..