Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8EFDD4769C6 for ; Wed, 11 Sep 2002 23:09:06 -0400 (EDT) Received: from joeconway.com (unknown [63.210.180.150]) by postgresql.org (Postfix) with ESMTP id BBE0E4769C4 for ; Wed, 11 Sep 2002 23:09:05 -0400 (EDT) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 3.5.9) with ESMTP-TLS id 1326750; Wed, 11 Sep 2002 19:51:11 -0700 Message-ID: <3D8004E4.80004@joeconway.com> Date: Wed, 11 Sep 2002 20:07:16 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Beth Gatewood Cc: 'Christopher Kings-Lynne' , pgsql-sql@postgresql.org Subject: Re: writing a function to mimic mysql last_insert_id References: <000f01c25a05$5c549aa0$0c00000a@bethvizx> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/89 X-Sequence-Number: 9366 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