[Hope this is the right mailing list!]
Hi,
This summer I have developed a html-based shopping system, and
I decided to use PostgreSQL for storing data. It works fine, but I
have run into an access problem. More specific: locking problem.
In my DB I have a special table, which have a column called 'ID',
and I want this to be unique, so I do something like this:
pseudo-code:
1. ID = (select max(ID) from mytable)
2. ID = ID + 1
3. insert into mytable values (ID,...)
But here comes the problem. When the PostgreSQL has a long que
of pseudo-code line 1, different processes are getting the same ID,
and the same increased ID will be inserted into mytable, and my
unique ID rule has been broken!
So how can I lock PostgreSQL before line 1, and release the lock
after line 3? Or can this pseudo sequence be done with only one
call to PostgreSQL to make unique values?
Please help me, and please send me a copy to my e-mail.
Thank you.
Steffen E. Thorkildsen