On Tuesday 05 December 2006 08:19, Michael Lackhoff wrote: > Hello, > > I need some pseudo-unique numbers like invoice numbers. They start every > year with 1, so autoincrement won't work. My idea was to use a helper > table with just just two fields 'year' and 'last_used_number'. Is it > enough to create a two column unique key or would it be better to do > something along these lines: > - lock table (or row?) > - read last_used_number for the year > - increment it > - save > - unlock > > Is there an idiom for this kind of task? And how can I do it with RDBO? > (I did a search for 'lock' in the docs and didn't find anything)
Are you using postgresql? If so, could you use a sequence and set the sequence back to 1 at a specified time each year? Sean ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object