Re: Serial type currval

From: Richard Huxton <dev(at)archonet(dot)com>
To: Oleg Lebedev <oleg(dot)lebedev(at)waterford(dot)org>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Serial type currval
Date: 2003-09-12 18:42:33
Message-ID: 200309121942.33335.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 12 September 2003 17:09, Oleg Lebedev wrote:
> I am wondering if it's possible to retrieve the current value of a
> serial type field without using the name of the corresponding sequence?
> I know that currval function takes the sequence name as a parameter, but
> I would like to use the name of the serial field instead. Is this
> possible?
> Thanks.

Well as it happens, a table "foo" with a serial field "bar" will have a
sequence called "foo_bar_seq" - so you can figure it out from the field name.
I don't know if this is *guaranteed* to always be that way, but it's been
that way for a while, and I can't see the developers changing it in a hurry.

Be careful if the name gets too long and gets trimmed.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-09-12 18:50:27 Re: Regarding constraint database
Previous Message Kathy Zhu 2003-09-12 18:06:58 Re: Converting database-encoding from SQL_ASCII to UNICODE?????