hi
lets have, say, invoice-numbers. 
a completely new invoice has new invoice-number.
same invoice may have many versions - the invoice-number does not 
change.

how to safely generate a new number for each new document (lets say it 
is simple number-incrementing)? 

one safe and simple way i've just invented is to have a separate table 
of one column - the invoice-numbers - and have a foreign key to it. 
First version of new invoice will create a row in the table and link 
to it, other versions of the invoice keep the link. Besides the 
simplicity this allows for any numbering scheme - whatever one puts 
there; even the table may have just primary id if just rowids are 
enough.

More space-savvy way is to have just one table with a row per 
numbering-type (one for invoice-numbers, one for account-numbers, 
employee-numbers etc), and for a new document increment the 
respective row and get its value. If there are sequences, this seems 
alright, the whole operation is atomic. 

But if there are no sequences, i cannot make this multi-access safe. 
atomic updates are alright for avoiding races, but reading the value 
after that - no guarantee it is right one, another atomic update may 
have sneaked in meanwhile. Any help here?
or should i use locking? im trying to avoid it...

ciao
svilen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to