RDOHELP72.HLB  —  DEFINE_FIELD
    Creates a global field definition.

    When the DEFINE FIELD statement executes, Oracle Rdb adds the field
    definition to the physical database. A field definition includes
    a name, a data type, and a set of optional clauses.

    Example:

    DEFINE FIELD LABEL
       DATATYPE IS TEXT SIZE IS 8 CHARACTERS
       MISSING_VALUE IS "Not here"
       VALID IF LABEL =  "Good"       OR
                LABEL =  "Bad"        OR
                LABEL =  "Mediocre"   OR
                LABEL MISSING
       QUERY_HEADER FOR DATATRIEVE IS "Column"/"Label".

1  –  More

    To define a field using the DEFINE FIELD statement, you must have
    the Oracle Rdb DEFINE privilege for the database.

    If you have invoked the database with the PATHNAME specification,
    the field definition is also added to the data dictionary. Once
    you have defined a field globally, any relation can use the
    field definition by using the field name in the DEFINE or CHANGE
    RELATION statement.

    You can copy a shareable field definition from the data
    dictionary into the database.

    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 FIELD statement.

2  –  Format

  (B)0DEFINE FIELD qqqqqqqqq> name qqqqqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqqqqqk
                                                                        x
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  x
  mqwqqqq> FROM PATHNAME qqqqqqqqqqqqqqq> path-name qqqqqq>qqqqqqqwqqqq> .
    x                                                             x
    mqwqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqwqqq> field-attributes qqqqqj
      mq> DESCRIPTION IS /* text */ qqj

2.1  –  name

    Name of the field you want to create. You must use a field name
    that conforms to OpenVMS naming conventions.

2.2  –  path-name

    A full or relative data dictionary path name specifying the
    source of the field definition. You must invoke the database by
    path name if you plan to copy a shareable field definition from
    the data dictionary.

    The name you give to the field must match the name of the field
    in the data dictionary. You cannot rename a shareable field.

2.3  –  text

    A text string that adds a comment to the field definition.

2.4  –  field-attributes

    A list of definitions that indicate what type of data you can
    store in the field and how Oracle Rdb uses that data. The field
    attributes include the data type and the following optional
    clauses:

    o  VALID IF

    o  MISSING_VALUE

    o  DATATRIEVE support clauses

 Do not use multiple, conflicting clauses in a field definition.

    For a complete description of field attributes, ask for HELP on
    Field_attr.

3  –  Examples

    Example 1: Using DEFINE FIELD

    DEFINE FIELD STANDARD_ID_NUMBER
        DATATYPE IS SIGNED LONGWORD.

    This statement gives a name to the field and specifies its data
    type.

    Example 2: Using DEFINE FIELD with VALID IF

    DEFINE FIELD SEX
       DATATYPE IS TEXT SIZE IS 1
       VALID IF SEX = "M" OR SEX = "F".

    This definition provides validation criteria. When a user tries
    to enter a value other than "M" or "F" in a field that refers to
    this definition, Oracle Rdb returns an error message.

    Example 3: Using DEFINE FIELD with DATATRIEVE Support

    DEFINE FIELD SALARY_AMOUNT
        DATATYPE IS SIGNED LONGWORD
        DEFAULT_VALUE FOR DATATRIEVE IS 0
        EDIT_STRING FOR DATATRIEVE IS "$$$$,$$9.99".

    This example adds a DATATRIEVE edit string and default value to
    the name and data type.

    Example 4: Copying a Field from the data dictionary

    DEFINE FIELD SALARY_AMOUNT
      FROM PATHNAME 'DISK1:[CDDPLUS.DEFS]PERS.SALARY_AMOUNT'.

    This example copies the shareable field, SALARY_AMOUNT, from the
    dictionary.
Close Help