Re: Return the primary key of a newly inserted row? - Mailing list pgsql-general

From Tim Allen
Subject Re: Return the primary key of a newly inserted row?
Date
Msg-id 449A1539.8000004@proximity.com.au
Whole thread Raw
In response to Return the primary key of a newly inserted row?  (John Tregea <john@debraneys.com>)
Responses Re: Return the primary key of a newly inserted row?
Re: Return the primary key of a newly inserted row?
List pgsql-general
John Tregea wrote:
> Greeting again,
>
> I am writing records to postgreSQL from an IDE called revolution. At the
> time I perform the INSERT command I need to retrieve the value of the
> serial_id column from the newly created row.
>
> Is it possible to have a specified column value returned after the
> INSERT (rather than the number of rows affected) ?
>
> That would save me doing a SELECT select statement after every INSERT.
>
> Please excuse the terminology if it is not SQL'esque, but I hope you
> know what I am getting at.
>
> Thanks in advance
>
> John Tregea

It's not supported now, however it has been discussed several times, and
there is a TODO entry for it at

http://www.postgresql.org/docs/faqs.TODO.html

using syntax along the lines of INSERT ... RETURNING ...

Search for the word "returning" in the todo list and you'll find the
entry. Your options include waiting for someone to make it happen (no
telling how long that will be), or helping to make it happen (for which
we would all thank you :-) ). In the meantime you'll have to work around
it, as you suggested.

Tim

--
-----------------------------------------------
Tim Allen          tim@proximity.com.au
Proximity Pty Ltd  http://www.proximity.com.au/

pgsql-general by date:

Previous
From: John Tregea
Date:
Subject: Re: Return the primary key of a newly inserted row?
Next
From: John Tregea
Date:
Subject: Re: Return the primary key of a newly inserted row?