Re: List last value of all sequences

From: greg(at)turnstep(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: Re: List last value of all sequences
Date: 2003-07-24 19:32:27
Message-ID: c2f07882d3334ed7842928ee80195d64@biglumber.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> The main problem with this approach is that, while you get the "current
> value", the sequence is incremented by the call. I just want to
> (strictly) look at the value.

The sequence values do not change: test it for yourself.

> IF l_last_value = 0 THEN
> PERFORM setval(l_sequence_name,1, False);
> ELSE
> PERFORM setval(l_sequence_name,l_last_value);
> END IF;

Pretty good idea; just beware of sequences that do not start at 1 :)

- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200307241520

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE/IDPUvJuQZxSWSsgRAv1MAJ9Ax8EpRTf2ElbdeN/hjMIkWSpPqwCgqAVV
Xgese545H2Qa4Znwt1Y7AlE=
=IkFq
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2003-07-24 19:32:34 Re: SAP DB: The unsung Open Source DB
Previous Message Nailah Ogeer 2003-07-24 19:21:41 Re: Postgres hash tables