X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5DA76D1B960 for ; Mon, 1 Sep 2003 18:18:31 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 62144-06 for ; Mon, 1 Sep 2003 15:18:00 -0300 (ADT) Received: from seapdc01.PNTS (ip63.c216.blk1.bel.nwlink.com [209.20.216.63]) by svr1.postgresql.org (Postfix) with ESMTP id E05BDD1B91B for ; Mon, 1 Sep 2003 15:17:58 -0300 (ADT) Received: from busbydev (BUSBY-DEV [10.0.0.17]) by seapdc01.PNTS with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id R3LG0LD1; Mon, 1 Sep 2003 11:35:38 -0700 Message-ID: <02dd01c370b4$69873a40$1100000a@busbydev> Reply-To: "David Busby" From: "David Busby" To: "Andrei Verovski (aka MacGuru)" , References: Subject: Re: Get last serial (autoincrement) value Date: Mon, 1 Sep 2003 11:11:06 -0700 Organization: Pacific Northwest Ticket Service MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/2 X-Sequence-Number: 2279 select currval('table_id_column_seq'); ----- Original Message ----- From: "Andrei Verovski (aka MacGuru)" To: Sent: Monday, September 01, 2003 03:34 Subject: [PHP] Get last serial (autoincrement) value > Hi, > > Anyone knows how to obtain last inserted serial (autoincrement) id? I > am currently using "SELECT id FROM table_name ORDER BY id DESC", and > then retrieve first row and desired value. > > May be there is more elegant way? I am using ADODB. ADODB has function > which in theory allows to obtain > last inserted serial (autoincrement) id, but for Postgres it return OID. > > This is from ADODB manual: > > Insert_ID( ) > Returns the last autonumbering ID inserted. Returns false if function > not supported. > Only supported by databases that support auto-increment or object id's, > such as PostgreSQL, MySQL and MSSQL currently. PostgreSQL returns the > OID, which can change on a database reload. > > > Thanks in advance for any suggestion. > > > ********************************************* > * Best Regards --- Andrei Verovski > * > * Personal Home Page > * http://snow.prohosting.com/guru4mac > * Mac, Linux, DTP, Development, IT WEB Site > ********************************************* > > > ---------------------------(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