Skip to content
This repository

Support for last insert id #1

RJ opened this Issue July 12, 2010 · 2 comments

2 participants

Richard Jones Will Glozer
Richard Jones
RJ commented July 12, 2010

Couldn't see how to do this, is it possible?

When inserting into a table with an auto incrementing/SERIAL primary key


Will Glozer
wg commented July 12, 2010

Did you try using the RETURNING clause? For example if you had a table named "table" with two columns, "id" and "value" where the id column is of type serial:

INSERT INTO "table" (value) VALUES ('foo') RETURNING id;

Richard Jones
RJ commented July 13, 2010

This does the trick, thanks a lot.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.