On Tuesday 24 June 2008 19:32:19 Jorge Godoy wrote: > Bobby Impollonia wrote: > > In mysql you can declare a integer column to be auto_increment > > and it will handle for you giving each row a different number. > > Other databases have similar mechanisms. It sounds like the > > invoice number is the primary key for the invoice table? If you > > have a integer primary key in sqlalchemy, it assumes that you > > want to make it auto increment so this should all happen > > automatically. > > I don't think this would work for invoices. What happens if a > transaction is rolled back in MySQL an an auto-increment column is > used? In PostgreSQL, using sequences, the number would be lost > forever. > > Invoices usually require a continuous numbering and should have no > holes in the sequence. > > What is the best solution is to have a table where you'll store the > numbers, access it in a serializable way and then create and remove > locks. This will grant that you don't have holes and that you > don't have repeated numbers allocated to different invoices.
mmm yes, there is this things also. Some numbering schemes allow/force holes, others not. There can be also hierarchical numbering schemes, e.g. employee is 1-31-52 maybe a table is really the most flexible way of doing it... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---