Re: MySQL LAST_INSERT_ID() to Postgres

From: Russ Brown <pickscrape(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: MySQL LAST_INSERT_ID() to Postgres
Date: 2008-08-28 19:51:21
Message-ID: 48B701B9.8010303@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2008-08-28 19:56:44 Re: MySQL LAST_INSERT_ID() to Postgres
Previous Message Alan Hodgson 2008-08-28 19:49:24 Re: WAL file questions - how to relocate on Windows, how to replay after total loss, etc