"Keyed" sequence? - Mailing list pgsql-general

From Israel Brewster
Subject "Keyed" sequence?
Date
Msg-id 2926B083-33C9-4648-8635-BC293C70ED45@ravnalaska.net
Whole thread Raw
Responses Re: "Keyed" sequence?
Re: "Keyed" sequence?
List pgsql-general
This is probably crazy talk, but in Postgresql is there any way to have a "keyed" sequence? That is, I have a table with a list of departments. While *relatively* static, technically speaking this is a dynamic list - someone certainly could decide to add a department, or combine two departments into one new one, whatever. In any case, I would ideally like to have a sequence per department, but since the list is dynamic it's not as simple as creating 33 independent sequences and then having a lookup table somewhere, although I guess I could implement something of the sort with triggers.

Is there any elegant way of accomplishing this? Something like SELECT nextval('department_seq['ops'])?

-----------------------------------------------
Israel Brewster
Systems Analyst II
Ravn Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7293
-----------------------------------------------



Attachment

pgsql-general by date:

Previous
From: Steve Atkins
Date:
Subject: Re: CREATE EXTENSION without superuser access
Next
From: Vik Fearing
Date:
Subject: Re: "Keyed" sequence?