"Grand Titus" <grand.titus@free.fr> writes:
> And I don't know how to unlock a table, I can't find the command 'UNLOCK'.
There is no UNLOCK short of committing your transaction. If you had
one, your code would not work anyway (because you'd be unlocking the
table before the next guy could see your uncommitted updates).
I'd suggest using an optimistic-locking approach instead: don't lock
at all, just rely on unique indexes to prevent duplicate insertions.
Once in a while you will get a collision, and then you'll have to
roll back your transaction and try again --- but if that only seldom
happens, it's a lot faster than locking every time.
regards, tom lane