Adding a cheque number primary key would work tho'
Depending on the specifics of the application, check number may not be a 'unique' field. Automatic bank checks come to mind, on my monthy statments they tend to always have the same check number or none at all.
In this case I'd use a serial column.
The best long term solution, IMHO, would be to change postgres so that
it has a unique system column for each record, like Oracle does.
Eh? The expense of having a 64-bit column with index and unique constraint on every table, whether I need it or not?
[soapbox = on]
The problem was a simple one. The original poster wanted to distinguish between rows where there was no key. Without a key this is impossible. The table should not have been created without a primary key defined, and in the absence of adequate information to make a design decision the best that can be offered is an auto-generated sequence.
[soapbox = off]
-- Richard Huxton Archonet Ltd
---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster