On Mon, 24 Jan 2005, William Yu wrote:
> If you absolutely need the display field to be unique and it has to be a
> sequence starting from 1 -- it's simplicity itself. Use the
> serialization errors to your advantage. If you try to insert a record
> and you get a dupe key violation, just increment your seq counter by 1
> and try again. Keep trying until you succeed. No need to lock the tables
> at all.
Just trial and error ?
I don't think its a very good solution. Then you have to figure out
exactly which error it is and which column caused the violation. (How ? By
parsing the error string ???)
And if the correct error was returned you retry the query... But how many
times ? Just once ? or a 1000 times ?
I'm sorry but I think this solution is just a Q&D hack.