Re: MySQL LAST_INSERT_ID() to Postgres - Mailing list pgsql-general

From Russ Brown
Subject Re: MySQL LAST_INSERT_ID() to Postgres
Date
Msg-id 48B701B9.8010303@gmail.com
Whole thread Raw
In response to MySQL LAST_INSERT_ID() to Postgres  ("Masis, Alexander \(US SSA\)" <alexander.masis@baesystems.com>)
Responses Re: MySQL LAST_INSERT_ID() to Postgres  (Alvaro Herrera <alvherre@commandprompt.com>)
List 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;

pgsql-general by date:

Previous
From: Alan Hodgson
Date:
Subject: Re: WAL file questions - how to relocate on Windows, how to replay after total loss, etc
Next
From: "Douglas McNaught"
Date:
Subject: Re: WAL file questions - how to relocate on Windows, how to replay after total loss, etc