Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Support for last insert id #1

Closed
RJ opened this Issue Jul 13, 2010 · 2 comments

Comments

Projects
None yet
2 participants

RJ commented Jul 13, 2010

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

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

Thanks!

Owner

wg commented Jul 13, 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;

RJ commented Jul 13, 2010

This does the trick, thanks a lot.
RJ

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment