On Wed, Nov 27, 2002 at 06:15:04PM +0100, SZUCS Gábor wrote:
> 2. There is something called currval(...) that doesn't increase the counter,
> just returns its current value. In our lucky case, you need something that
> can be queried with this function, so I'd say either of the following will
> do:
>
> SELECT * FROM product WHERE prodid = currval('prodid_seq');
> SELECT * FROM product ORDER BY prodid DESC LIMIT 1;
>
> Both of these, however, assume that you haven't inserted any rows after the
> one in question.
Wrong. The second one does. The first guarenteed to return what the earlier
nextval() returned. It is therefore the recommended method. Lookup the
documentation for more details.
Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
> Support bacteria! They're the only culture some people have.