[Zope] OT: Manual unique sequences in RDBMS

Carlos A. Carnero Delgado texel@rtvc.com.cu
Tue, 13 Jun 2000 13:58:59 -0400


Hello Zopistas,

This is a little off-topic but I had no other place to ask. I'm using
Zope & PostgreSQL together on a intranet accounting system (BTW, it's
Open Source and I'll post it soon.)

Anyway, I have several tables related by ids (keys), and I have to
create these keys by myself. They're of the form YYYYMMDDCCCCCC (Y:
year, M: month, D: day, C: a consecutive transaction number that I must
generate) and they must be unique. Of course, from day to day, these
numbers are guaranteed to be unique, my problem relies on
Intra-Day-Uniqueness (TM).

How could I generate the consecutive part? Unfortunately, I can't use
the underlaying RDBMS auto-numbering or auto-sequence feature. Since the
keys _must_ conform to the above scheme. All I can count on is on the
database rows (an ideal solution would be conceptually independent of
both Zope and PostgreSQL).

I was even thinking of having a separate table having the last
transaction number stored in a single row which would be updated by
locking the table... just a thought. Of course, this would be a
multiuser environment. Any one?

Best regards and TIA,
--
[ c a r l o s  c a r n e r o ]
[ r t v  c o m e r c i a l ]
[ t e x e l @ r t v c . c o m . c u ]