Re: MySQL LAST_INSERT_ID() to Postgres
От
Magnus Hagander
Тема
Re: MySQL LAST_INSERT_ID() to Postgres
Дата
Msg-id
48B7A81A.9050506@hagander.net
Ответ на
Re: MySQL LAST_INSERT_ID() to Postgres (Alvaro Herrera)
Список
Дерево обсуждения
MySQL LAST_INSERT_ID() to Postgres "Masis, Alexander \(US SSA\)" <alexander.masis@baesystems.com>
Re: MySQL LAST_INSERT_ID() to Postgres Russ Brown <pickscrape@gmail.com>
Re: MySQL LAST_INSERT_ID() to Postgres Alvaro Herrera <alvherre@commandprompt.com>
Re: MySQL LAST_INSERT_ID() to Postgres Magnus Hagander <magnus@hagander.net>
Re: MySQL LAST_INSERT_ID() to Postgres Alvaro Herrera <alvherre@commandprompt.com>
Re: MySQL LAST_INSERT_ID() to Postgres Bill <pg@dbginc.com>
Re: MySQL LAST_INSERT_ID() to Postgres Raymond O'Donnell <rod@iol.ie>
Re: MySQL LAST_INSERT_ID() to Postgres Tom Lane <tgl@sss.pgh.pa.us>
Re: MySQL LAST_INSERT_ID() to Postgres Raymond O'Donnell <rod@iol.ie>
Re: MySQL LAST_INSERT_ID() to Postgres Lennin Caro <lennin.caro@yahoo.com>
Re: MySQL LAST_INSERT_ID() to Postgres "Scott Marlowe" <scott.marlowe@gmail.com>
Re: MySQL LAST_INSERT_ID() to Postgres Steve Atkins <steve@blighty.com>
Re: MySQL LAST_INSERT_ID() to Postgres Bill <pg@dbginc.com>
Re: MySQL LAST_INSERT_ID() to Postgres "Scott Marlowe" <scott.marlowe@gmail.com>
Re: MySQL LAST_INSERT_ID() to Postgres Joshua Drake <jd@commandprompt.com>
Re: MySQL LAST_INSERT_ID() to Postgres "Scott Marlowe" <scott.marlowe@gmail.com>
Re: MySQL LAST_INSERT_ID() to Postgres Joshua Drake <jd@commandprompt.com>
Re: MySQL LAST_INSERT_ID() to Postgres "D. Dante Lorenso" <dante@lorenso.com>
Re: MySQL LAST_INSERT_ID() to Postgres Christophe <xof@thebuild.com>
Re: MySQL LAST_INSERT_ID() to Postgres Bill <pg@dbginc.com>
Re: MySQL LAST_INSERT_ID() to Postgres Joshua Drake <jd@commandprompt.com>
Re: MySQL LAST_INSERT_ID() to Postgres "Scott Marlowe" <scott.marlowe@gmail.com>
Alvaro Herrera wrote:
> Russ Brown escribió:
>> Masis, Alexander (US SSA) wrote:
>>> "SELECT CURRVAL(
>>> pg_get_serial_sequence('my_tbl_name','id_col_name'));"
>> Any reason why you can't just do this?
>>
>> CREATE FUNCTION last_insert_id() RETURNS bigint AS $$
>> SELECT lastval();
>> $$ LANGUAGE SQL VOLATILE;
>
> If your table has a trigger that inserts into another table with its own
> sequence, you're screwed.
I assume you're equally screwed with MySQL LAST_INSERT_ID() in that case
- so it'd be bug compatible.
I know MSSQL had similar issues with the use of @@IDENTITY - which is
why they went down the ugly path of SCOPE_IDENTITY(). Why they didn't
just implement RETURNING, I have no idea...
//Magnus
В списке pgsql-general по дате отправления