Subject violation of PRIMARY or UNIQUE KEY constraint
Author Tim Ward
So I've got this transaction which tries to create records in a table and gets

"violation of PRIMARY or UNIQUE KEY constrain"

There are, I believe, no records in the table visible to the same transaction with the same primary key, as the insertion code checks first, and doesn't attempt to insert a record that's already there.

Now, I seem to recall seeing somewhere that actually a primary key (and any other unique index?) is independent of transactions, so the following:

(1) Transaction A inserts record X
(2) Transaction B attempts to insert record X (having first checked that it doesn't exist, which it doesn't as far as transaction B is concerned, because transaction A hasn't committed yet)

results in the error.

Have I remembered this behaviour of primary keys correctly? Please could someone remind me where the documentation is if so?
-- 
Tim Ward