X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 15EFE8BA03D; Fri, 4 Feb 2005 14:13:21 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16377-04; Fri, 4 Feb 2005 14:13:11 +0000 (GMT) Received: from dfw-gate3.raytheon.com (dfw-gate3.raytheon.com [199.46.199.232]) by svr1.postgresql.org (Postfix) with ESMTP id B15CC8B9F06; Fri, 4 Feb 2005 14:13:13 +0000 (GMT) Received: from ds02c00.directory.ray.com (ds02c00.directory.ray.com [147.25.138.118]) by dfw-gate3.raytheon.com (8.12.10/8.12.10) with ESMTP id j14EDBTB007684; Fri, 4 Feb 2005 08:13:11 -0600 (CST) Received: from ds02c00 (localhost [127.0.0.1]) by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id j14ED7HO027506; Fri, 4 Feb 2005 14:13:07 GMT Received: from ds02c00.directory.ray.com with LMTP by ds02c00 (2.0.6/sieved-2-0-build-559); Fri, 4 Feb 2005 14:13:06 +0000 Received: from notesserver5.ftw.us.ray.com (notesserver5.ftw.us.ray.com [151.168.145.35]) by ds02c00.directory.ray.com (Switch-3.1.4/Switch-3.1.0) with ESMTP id j14ECw16027399 sender Richard_D_Levine@raytheon.com; Fri, 4 Feb 2005 14:12:58 GMT Subject: Re: getting back autonumber just inserted To: Scott Marlowe Cc: lorid , pgsql-sql@postgresql.org, pgsql-sql-owner@postgresql.org X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: Richard_D_Levine@raytheon.com Date: Fri, 4 Feb 2005 09:11:32 -0500 X-MIMETrack: Serialize by Router on NotesServer5/HDC(Release 6.5.2|June 01, 2004) at 02/04/2005 09:12:58 AM MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII X-SPAM: 0.00 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.183 tagged_above=0 required=5 tests=AWL, NO_REAL_NAME X-Spam-Level: X-Archive-Number: 200502/89 X-Sequence-Number: 20200 I don't work with M$ DBs, but saw that "autonumber" is an M$ concept. Purely for my own edification, how do you get the most resent value of an autonumber in M$? I was helping someone out who was using M$ stuff and was amazed that there was no currval function. Thanks, Rick Scott Marlowe orks.com> cc: pgsql-sql@postgresql.org Sent by: Subject: Re: [SQL] getting back autonumber just inserted pgsql-sql-owner@pos tgresql.org 02/03/2005 05:16 PM On Thu, 2005-02-03 at 16:16, lorid wrote: > I could have sworn I kept a copy of prior emails that discussed how to > get back a value that was just inserted into a autonumber (or in > postgresql case a sequence number) If you know the name of the sequence the number came from you can use currval(): insert into table1 (info) values ('abc'); select currval('table1seq'); Assuming table1seq is the name of the sequence here. In 8.0 there's a function to do this (I'm not sure of the name, but a quick search of the 8.0 docs should turn it up.) ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly