From: | "David Busby" <busby(at)pnts(dot)com> |
---|---|
To: | "Andrei Verovski (aka MacGuru)" <andreil1(at)mail(dot)starlett(dot)lv>, <pgsql-php(at)postgresql(dot)org> |
Subject: | Re: Get last serial (autoincrement) value |
Date: | 2003-09-01 18:11:06 |
Message-ID: | 02dd01c370b4$69873a40$1100000a@busbydev |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
select currval('table_id_column_seq');
----- Original Message -----
From: "Andrei Verovski (aka MacGuru)" <andreil1(at)mail(dot)starlett(dot)lv>
To: <pgsql-php(at)postgresql(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2003-09-01 18:48:30 | Re: Get last serial (autoincrement) value |
Previous Message | Andrei Verovski (aka MacGuru) | 2003-09-01 10:34:32 | Get last serial (autoincrement) value |