CDO$HELP.HLB  —  CDO Commands, DEFINE  RECORD Constraint, Examples
  CDO>  DEFINE RECORD PARTS
  cont> CONSTRAINT PARTS_PMK PRIMARY KEY PART_ID
  cont> CONSTRAINT PARTS_UNQ UNIQUE PART_NO
  cont> CONSTRAINT PART_CST CHECK
  cont> ANY P IN PARTS WITH (PART_ID IN PARTS = PART_ID_USED_IN IN PARTS)
  cont> CONSTRAINT PART_FRK
  cont> FOREIGN KEY PART_NO REFERENCES PARTS PART_ID.
  cont> PART_NO.
  cont> PART_ID.
  cont> PART_ID_USED_IN.
  cont> PART_QUANT.
  cont> END.
  CDO> SHOW RECORD PARTS/FULL
  Definition of record PARTS
  |   Contains field           PART_NO
  |   |   Datatype                 signed word
  |   Contains field           PART_ID
  |   |   Datatype                 signed longword
  |   Contains field           PART_ID_USED_IN
  |   |   Based on                 ID_DOM
  |   |   |   Datatype                 signed longword
  |   Contains field           PART_QUANT
  |   |   Datatype                 signed word
  |   Constraint PARTS_PMK  primary key PART_ID NOT DEFERRABLE
  |   Constraint PARTS_UNQ  unique PART_NO NOT DEFERRABLE
  |   Constraint PART_CST (ANY (P IN PARTS WITH (PART_ID IN PARTS EQ
  PART_ID_USED_IN IN PARTS))) NOT DEFERRABLE
  |   Constraint PART_FRK  foreign key PART_NO references PARTS PART_ID NOT
  DEFERRABLE

      This example uses the CDO DEFINE RECORD command syntax to
      establish constraints on the PARTS record.

                                   NOTE

       For the purposes of this example, it is assumed that the
       field definitions referred to in the record definitions have
       already been defined in the repository.

      This example assumes the PART_ID to be the primary key and
      the PART_NO to be a unique value across all possible parts.
      By not specifying whether the constraints are deferrable,
      the default evaluation time is accepted. In CDO, the default
      evaluation time for constraints is NOT DEFERRABLE. Constraints
      are evaluated at statement time.

      Using CDO, the record PARTS is defined with the following
      attributes:

      o  Primary key PARTS_PMK

      o  Unique constraint PARTS_UNQ

      o  Check constraint PART_CST

      o  Foreign key constraint PART_FRK
Close Help