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 3C7E5D1B496 for ; Sat, 24 Apr 2004 14:37:54 -0300 (ADT) 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 69282-07 for ; Sat, 24 Apr 2004 14:37:53 -0300 (ADT) Received: from emo.org.tr (emo.org.tr [195.142.105.9]) by svr1.postgresql.org (Postfix) with ESMTP id 56BD5D1B46C for ; Sat, 24 Apr 2004 14:37:52 -0300 (ADT) Received: by emo.org.tr (Postfix, from userid 41643) id 36BE2EE3DF; Sat, 24 Apr 2004 20:37:48 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by emo.org.tr (Postfix) with ESMTP id 315FB116255; Sat, 24 Apr 2004 20:37:48 +0300 (EEST) Date: Sat, 24 Apr 2004 20:37:44 +0300 (EEST) From: Devrim GUNDUZ X-X-Sender: devrim2@emo.org.tr To: Michael Satterwhite Cc: pgsql-sql@postgresql.org Subject: Re: Question re: serial In-Reply-To: <200404241224.05079.michael@weblore.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/268 X-Sequence-Number: 17643 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, On Sat, 24 Apr 2004, Michael Satterwhite wrote: > I have a table with a primary key defined as serial unique. When I insert a > row into the table, I need to get the value of that row back so that I can > use it to link rows in another table to it. How do I do that in Postgresql? I > know that I can define a sequence and insert the value manually, but is there > a way to query the value of the most recently inserted serial column of a > row? See currval() and nextval() functions: Regards, - -- Devrim GUNDUZ devrim@gunduz.org devrim.gunduz@linux.org.tr http://www.TDMSoft.com http://www.gunduz.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQFAiqXrtl86P3SPfQ4RAsxkAKCQ9oL9Jo4a7VZwqyI4YU6L7i3nEACgv/wM 0ce7up3AVctCYyksk7OYIpY= =8Hr5 -----END PGP SIGNATURE-----