Restart increment to 0 each year = re-invent the sequences mecanism ? - Mailing list pgsql-general

From Bruno Baguette
Subject Restart increment to 0 each year = re-invent the sequences mecanism ?
Date
Msg-id 408CD48F.3020101@baguette.net
Whole thread Raw
Responses Re: Restart increment to each year = re-invent the
Re: Restart increment to 0 each year = re-invent the sequences mecanism ?
List pgsql-general
Hello,

I have to design a table wich will store some action reports. Each
report have an ID like this 1/2004, 2/2004, ... and each years, they
restart to 1 (1/2004, 1/2005, 1/2006,...).

So, I was thinking to split that in two fields : one with the increment
and one with the year. But I don't know how can I manage the sequences
since I have to restart to 0 each year...

Do you think I should re-invent the sequences mecanism with a second
table and a stored procedure, only to manage theses 'home-made' sequences ?

Or should I create some sequences like myseq_2004, myseq_2004,
my_seq_2005,... and use a concatenation of the myseq_ string and the
current year when calling nextval and curvall ?

Or is there another way to do that ?

Thanks in advance :-)

--
Bruno Baguette - pgsql-ml@baguette.net

pgsql-general by date:

Previous
From:
Date:
Subject: Re: thread_test.c problems
Next
From: Juris Krumins
Date:
Subject: Re: cache lookup of relation 165058647 failed