SET UNIQUE

From Recital Documentation Wiki
Revision as of 15:51, 25 November 2009 by Helengeorge (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Purpose

Determine whether duplicate keys are to be included in index files


Syntax

SET UNIQUE ON | OFF | (<expL>)


See Also

APPEND, CHANGE, EDIT, Function Keys, INDEX, ON ERROR, REINDEX, REPLACE, SET PCUNIQUE, UNIQUE()


Description

If SET UNIQUE is ON when an index file is created or recreated, records with duplicate keys are discarded. The records still exist in the table, but there is no entry for them in the index file, so they are ’hidden’ from view. The unique status of the keys is stored in the index file, so whenever the index is associated with the table subsequently, the uniqueness of keys that are added to the index file is enforced.

If an attempt is made to add a duplicate key to a unique index file, the operation will not be able to complete. If a record is being appended or changed in the table through a full screen forms based command such as APPEND or CHANGE, then the system displays an appropriate message. The form cannot be exited until data entry is abandoned by pressing the [ABANDON] key, or a unique key is entered. If an attempt is made to update a record through the REPLACE command, an error message will be generated. This can be trapped with the ON ERROR command.

The UNIQUE keyword can also be included in the INDEX or REINDEX commands to provide the same effect as SET UNIQUE ON. By default, UNIQUE is OFF.


Example

use patrons
set unique on
index on name to persons


Products

Recital Server, Recital