Home | Previous Page | Next Page   Design Decisions > Supporting Data Retrieval, Manipulation, and Return >

Enforcing Unique-Index Constraints

The UNIQUE or DISTINCT keyword in a CREATE INDEX or insert statement specifies that a secondary access method cannot insert multiple occurrences of a key value. The UNIQUE or DISTINCT keyword in a SELECT statement specifies that the access method must return only one occurrence of a key value.

To provide support for unique keys
  1. Program the am_insert purpose function to scan an index before it inserts each new entry and raise an exception for a key value that the index already contains.
  2. Program the am_getnext to return only one occurrence of a key.
  3. Set the am_unique purpose flag, as described in Setting Purpose Functions, Flags, and Values.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]