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 D013DD1B550 for ; Mon, 1 Sep 2003 10:36:07 +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 31805-02 for ; Mon, 1 Sep 2003 07:35:38 -0300 (ADT) Received: from linux-web.starlett.lv (starlet.delfi.lv [195.114.46.32]) by svr1.postgresql.org (Postfix) with ESMTP id 19923D1B52C for ; Mon, 1 Sep 2003 07:35:34 -0300 (ADT) Received: from starlett.lv ([192.168.0.141]) by linux-web.starlett.lv (8.12.3/8.11.6) with ESMTP id h81AS4Yt021943 for ; Mon, 1 Sep 2003 13:28:04 +0300 Date: Mon, 1 Sep 2003 13:34:32 +0300 Mime-Version: 1.0 (Apple Message framework v552) Content-Type: text/plain; charset=US-ASCII; format=flowed Subject: Get last serial (autoincrement) value From: Andrei Verovski (aka MacGuru) To: pgsql-php@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: X-Mailer: Apple Mail (2.552) X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/1 X-Sequence-Number: 2278 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 *********************************************