From: David Busby <busby@pnts.com>
To: Andrei Verovski (aka MacGuru) <andreil1@mail.starlett.lv>
To: pgsql-php@postgresql.org
Subject: Re: Get last serial (autoincrement) value
Date: Mon, 1 Sep 2003 11:11:06 -0700
Message-ID: <02dd01c370b4$69873a40$1100000a@busbydev> (raw)
References: <DF9C8135-DC67-11D7-B235-000A959C9730@starlett.lv>
select currval('table_id_column_seq');
----- Original Message -----
From: "Andrei Verovski (aka MacGuru)" <andreil1@mail.starlett.lv>
To: <pgsql-php@postgresql.org>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: busby@pnts.com, andreil1@mail.starlett.lv
Subject: Re: Get last serial (autoincrement) value
In-Reply-To: <02dd01c370b4$69873a40$1100000a@busbydev>
References: <DF9C8135-DC67-11D7-B235-000A959C9730@starlett.lv> <02dd01c370b4$69873a40$1100000a@busbydev>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox