X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3924CD1B51E for ; Sat, 15 Nov 2003 15:18:52 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 37609-05 for ; Sat, 15 Nov 2003 11:18:24 -0400 (AST) Received: from guinness.cs.stevens-tech.edu (guinness.cs.stevens-tech.edu [155.246.89.8]) by svr1.postgresql.org (Postfix) with ESMTP id D7E7ED1B4F1 for ; Sat, 15 Nov 2003 11:18:19 -0400 (AST) Received: by guinness.cs.stevens-tech.edu (Postfix, from userid 4405) id A06F8141697; Sat, 15 Nov 2003 10:18:08 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by guinness.cs.stevens-tech.edu (Postfix) with ESMTP id 8D90CC2463 for ; Sat, 15 Nov 2003 10:18:08 -0500 (EST) Date: Sat, 15 Nov 2003 10:18:08 -0500 From: Yasir Malik To: pgsql-sql@postgresql.org Subject: Getting last insert value Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/166 X-Sequence-Number: 15981 Hello, I have a table with many fields, and one of the fields is of type serial. I will do many inserts, and there will be many repeats of the other fields in the table, but, obviously, the serial field will be unique for all the rows. How can I get the value of serial field of the last row I inserted. I know I can select the maximum value from the serial field, but is there a better way, preferably something that takes constant time. Thanks, Yasir Malik