NYCPHP Meetup

NYPHP.org

[nycphp-talk] getting last inserted id with PostgreSQL

Matthew Terenzio webmaster at localnotion.com
Sat Nov 20 13:17:08 EST 2004


On Nov 20, 2004, at 12:42 PM, Jayesh Sheth wrote:

> It's not needed. The following works fine (if the tables exists of 
> course)
> and has no problems with concurrency:
>
> INSERT INTO foo(id,x) VALUES (DEFAULT, 'value');
> INSERT INTO bar(id,foo_ref) VALUES (DEFAULT, currval('foo_id_seq'));

This is what I wanted to know. If this is safe, all is good. Thanks




More information about the talk mailing list