Library /sys$common/syshlp/RDOHELP72.HLB  —  DEFINE_CONSTRAINT, More
    To define a constraint, you must have Oracle Rdb READ access to the
    database and Oracle Rdb READ and DEFINE access to all relations to
    which the constraint refers.

    When the DEFINE CONSTRAINT statement executes, the constraint
    definition is added to the physical database. If you have
    invoked the database using the PATHNAME argument, the constraint
    definition is also stored in the data dictionary.

    The DEFINE CONSTRAINT statement includes a record selection
    expression. Therefore, it is more flexible for checking values
    on input than the VALID IF clause. For example:

    o  VALID IF must be part of a DEFINE FIELD statement. Therefore,
       a VALID IF criterion applies to all the fields that use the
       definition. You can define a constraint that refers to only
       one of several relations that use a global field definition.

    o  VALID IF refers only to a range of literal values. You cannot
       use VALID IF to check a value against values of fields stored
       in the database. With DEFINE CONSTRAINT, you can check values
       from one relation against other database values, either in the
       same or another relation.

    o  You can use DEFINE CONSTRAINT to check for such conditions as
       existence, uniqueness, and nonexistence.

    Oracle Rdb evaluates constraints by validating existing data against
    the RSE specified by the constraint. If there is no existing data
    for Oracle Rdb to validate, the constraint will be defined without
    being evaluated.

    Oracle Rdb evaluates constraints at definition time; therefore,
    you cannot define a new constraint that violates an existing
    constraint.

    You can also specify that a constraint be checked when the
    STORE or MODIFY statement executes (CHECK ON UPDATE) or when
    the COMMIT statement executes (CHECK ON COMMIT). In this way,
    you can include interlocking constraints. For example, you might
    define two constraints to ensure that a department cannot exist
    without employees and an employee must belong to a department.
    However, if these two constraints were checked on UPDATE, there
    would be no way to create a new department. Instead, they should
    be checked on COMMIT. You can then create a department and give
    it members inside a single transaction, and check the constraints
    when the COMMIT statement ends the transaction.

    You can define a constraint only after you have invoked the
    database. See the INVOKE statement.

    You must execute this statement in a read/write transaction.
    If there is no active transaction and you issue this statement,
    Oracle Rdb starts a read/write transaction implicitly.

    Other users are allowed to be attached to the database when you
    issue the DEFINE CONSTRAINT statement.
Close Help