I'll try to explain (sorry about the delay - been busy with other things).
A column may be defined as either the PRIMARY KEY or as UNIQUE. This is usually done when you create the table, either by an SQL command from B4ppc or with an external utility.
This column will then not accept duplicate values. If you try to insert record where the column value already exist, an "error" message will be produced - something like "Abort due to constraint violation column field1 is not unique".
In my opinion, it is best to handle this event before the error occurs, by testing for the value before attempting any insert - as in the sample code. Your program can then take the appropriate action. This test could be done regardless of how the column is defined.
Hope that helps,
Geoff.
|