[ACCEPTED]-PHP Postgres: Get Last Insert ID-last-insert-id

Accepted answer
Score: 32

INSERT, UPDATE and DELETE in PostgreSQL 4 have a RETURNING clause which means you 3 can do:

INSERT INTO ....
RETURNING id;

Then the query will return the value 2 it inserted for id for each row inserted. Saves 1 a roundtrip to the server.

Score: 6

Yes, the sequence functions provide multiuser-safe methods for obtaining successive 1 sequence values from sequence objects.

More Related questions