By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,809 Members | 1,999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,809 IT Pros & Developers. It's quick & easy.

Sequences

P: n/a

I'm hoping someone can tell me I'm wrong, but I'm thinking not. Anyway,
here it goes:

Sequence information is stored in their individual 1-row tables, with
an entry is pg_class of relkind 'S'. So you can't
really get a list of sequences with last_value in a single query
without a butt-ugly pile of UNIONs in a query
manufactured after a query on pg_class (i.e. SELECT * FROM seq1 UNION
SELECT * FROM seq2...). And
the result would have no schema name with the sequence name, unless I
make my UNION query that much butt-uglier
(i.e. SELECT schema1 || '.' || sequence_name,last_value FROM seq1 UNION
SELECT schema1 || '.' || sequence_name,
last_value FROM seq2,...).

Tell me I have an elegant solution there, and I'll give you flattery
points but I'll still laugh at you.

Anyone have any other tricks?

--------------------

Andrew Rawnsley
President
The Ravensfield Digital Resource Group, Ltd.
(740) 587-0114
www.ravensfield.com
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 11 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Andrew Rawnsley <ro**@ravensfield.com> writes:
Sequence information is stored in their individual 1-row tables, with
an entry is pg_class of relkind 'S'. So you can't
really get a list of sequences with last_value in a single query


Nope, you can't ... and I surely hope you weren't expecting that the
last_values would all be simultaneously valid ...

What I'd try for this is

select relname, get_last_value(relname) from pg_class where relkind = 'S';

where get_last_value() is a plpgsql function that does an EXECUTE.
But you must realize that there will be time skew between the
last_values.

What is the problem you really want to solve?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 11 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.