"Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu> writes:
> create table foo (bar serial, baz text);
> insert into foo (baz) values ('wooble');
> select currval('foo_bar_seq');
I don't think this is safe in a multi-client environment;
what if someone else inserts at about the same time?
Better to doselect nextval('foo_bar_seq');insert into foo values (just-retrieved-value, 'wooble');
which is safer and probably marginally faster (since the
sequence object is touched only once, not twice).
regards, tom lane