On Thu, 18 Oct 2007, Michael Schmidt wrote:
> There is:
>
> SELECT currval(pg_get_serial_sequence('mytab','mycol'));
>
>
> Tried this as an isolated statement and it returned null, so it appears to
> also require that nextval be run before it can work.
>
No one was ever saying otherwise. All this discussion is focused around
the example that Andrei provided where an insert was done on a table with
a serial column.
In your case you're getting NULL because pg_get_serial_sequence returns
NULL for a column that doesn't have a sequence attached to it and currval
is STRICT. If you try this on something that is actually a serial column
you will get the expected error instead of NULL.
Kris Jurka