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.
Michael Schmidt
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
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера