Re: postgresql experts please help - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: postgresql experts please help
Date
Msg-id Pine.BSO.4.64.0710181817030.15177@leary.csoft.net
Whole thread Raw
In response to Re: postgresql experts please help  (Michael Schmidt <MichaelMSchmidt@msn.com>)
List pgsql-jdbc

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

pgsql-jdbc by date:

Previous
From: Michael Schmidt
Date:
Subject: Re: postgresql experts please help
Next
From: "Andrei Ilitchev"
Date:
Subject: Re: Fw: postgresql experts please help