Re: returning id - Mailing list pgsql-admin

From Lonni J Friedman
Subject Re: returning id
Date
Msg-id CAP=oouEkQAF1yrbBBFe=c9XAeM3awMpOndi=+8C_p-Jo0Roi=w@mail.gmail.com
Whole thread Raw
In response to returning id  (Marc Fromm <Marc.Fromm@wwu.edu>)
List pgsql-admin
On Tue, Sep 20, 2011 at 12:31 PM, Marc Fromm <Marc.Fromm@wwu.edu> wrote:
> Can I use “RETURNING id” in an insert statement with postgresql version
> 8.1.10?
>
> I cannot find a clear example on how to use it to capture the id created by
> the insert statement into a variable in PHP.
>
>
>
> Many examples are like this but don’t state how to access the returned id:
>
> INSERT INTO Addresses (address, city, state, postalcode) VALUES ('123 Main
> St.','Springfield','MA','01109') RETURNING id;
>

Is there a reason why you can't use the currval function:
select currval('id_seq')

pgsql-admin by date:

Previous
From: Marc Fromm
Date:
Subject: returning id
Next
From: Tom Lane
Date:
Subject: Re: returning id