DEFINE FIELD command

From m204wiki
Revision as of 01:04, 28 February 2013 by Alex (talk | contribs) (Automatically generated page update)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Summary

Privileges
Any user
Function
Defines the names and attributes of the fields in a Model 204 file

Syntax

DEFINE [FIELD] name [(attribute [attribute]...)]

or

DEFINE [FIELD] name WITH [attribute [attribute]...]

Where:

name (1 to 255 characters) must begin with a letter and can contain any alphanumeric characters (including space) except:

??

?$

?&

@ (or an alternative delete character)

# (or an alternative flush character)

 ;

name must not start with a reserved word or character. An embedded reserved word or character must be part of a string preceded and followed by a single quotation mark.

attribute is one of the field characteristics listed in the table below. Note that each attribute has a default. Therefore, when selected, the attribute need be specified only if it differs from the default. If no attributes are specified, the field is defined with all the defaults. All attributes are described in the Model 204 File Manager's Guide.
Field attributes
Attribute Abbreviation Default
AT-MOST-ONE

REPEATABLE

ONE

REPT

REPT (except in 1NF files)
BINARY BIN Not a binary field
BINARY-LARGE-OBJECT BLOB Not binary large object
CHARACTER-LARGE-OBJECT CLOB Not character large object
CODED

NON-CODED

COD

NCOD

NON-CODED
DEFERRABLE

NON-DEFERRABLE

DEF

NDEF

DEFERRABLE
FEW-VALUED

MANY-VALUED

FV

MV

MANY-VALUED
FLOAT FL Not a floating point field
FRV (for-each-value)

NON-FRV

--

NFRV

NON-FRV

KEY

NON-KEY

--

NKEY

NON-KEY

LENGTH m LEN No preallocated length
LEVEL k LVL No level
LRESERVE LRES 15
NRESERVE NRES 15
NUMERIC RANGE

NON-RANGE

RANGE, NR

NNR

NON-RANGE
OCCURS n OCC No preallocated occurrences
ORDERED

NON-ORDERED

ORD

NON-ORD

Non-ordered field
ORDERED CHARACTER ORD CHAR --
ORDERED NUMERIC ORD NUM --
SPLITPCT SPLT 50
IMMED IMM 1
PAD character -- PAD X'00'
STRING

BINARY

STR

BIN

STRING
UPDATE IN PLACE

UPDATE AT END

UP

UE

UPDATE IN PLACE
VISIBLE

INVISIBLE

VIS

INV

VISIBLE
UNIQUE

NON-UNIQUE

UNIQ

NUNIQ

NON-UNIQUE

Conflicting attributes, listed in the table below, cannot be specified together.

Conflicting field attributes
This attribute... Cannot be specified with the attribute(s)...
INVISIBLE NON-KEY, NON-RANGE, and NON-ORDERED
INVISIBLE UPDATE IN PLACE or UPDATE AT END
FRV NON-KEY
NON-CODED and NON-FRV MANY-VALUED or FEW-VALUED
NON-ORDERED, NON-KEY, and NON-RANGE DEFERRABLE or NON-DEFERRABLE
CODED, BINARY, CLOB, and BLOB LENGTH
NUMERIC RANGE OCCURS n (if n > 1)
FLOAT STRING, BINARY, NUMERIC RANGE, and INVISIBLE
OCCURS INVISIBLE
ORDERED FRV
ORDERED NUMERIC NUMERIC RANGE
LRESERVE NON-ORDERED
NRESERVE NON-ORDERED
SPLITPCT NON-ORDERED
IMMED NON-ORDERED
UNIQUE DEFERRABLE

Paired attributes, listed in the table below, must be specified together.

Paired field attributes
This attribute... Must be specified with the attribute(s)...
FLOAT LENGTH
OCCURS CODED, BINARY, or LENGTH
PAD LENGTH
UNIQUE ORDERED

Syntax notes

Attributes must be separated by commas or by one or more blanks.

You can specify DEFINE FIELD only in file context.

Example

DEFINE FIELD CUSTID WITH KEY FRV RANGE DEFINE FIELD AGE WITH KEY RANGE OCCURS 1 LENGTH 3 DEFINE FIELD EMPLOYEE

Usage notes

The DEFINE FIELD command describes the names and attributes of the fields in a Model 204 file. The file must be initialized, using the INITIALIZE command, before fields can be defined.

Note: Sort key fields for sorted files, hash key fields, and record security fields can be defined only with the INITIALIZE command, not with DEFINE.

Once fields have been defined, a user with the requisite privileges can perform the following functions on them:

  • Delete (DELETE command)

  • Display (DISPLAY command)

  • Redefine (REDEFINE command)

  • Rename (RENAME command)

You can define three types of floating point fields through the FLOAT and LENGTH attributes. The table below shows the characteristics of the three types.

Types of floating point fields
Type Number of bytes Maximum number of significant digits
Short precision 4 6
Long precision 8 15
Extended precision 16 31

You supply a LENGTH attribute of 4, 8, or 16. The following example defines a long-precision floating-point field:

DEFINE FIELD SALARY WITH FLOAT LEN 8

Consider making a field a floating-point field if its value is always or often numerical. Very large numbers or numbers with many significant digits use much less space in floating-point form than they do in character form. Floating-point fields are valid only for files with the format of Release 8.0 or later or that have been converted by the TRANSFORM FLOAT command. Floating-point numbers in ORDERED NUMERIC trees are discussed as follows.

The ORDERED attribute is used to define fields for the Ordered Index feature. The ORDERED attribute can be followed by a tree type to specify the kind of ordering for the index. The tree type can be either CHARACTER (CHAR) or NUMERIC (NUM). If a tree type is not provided, a default tree type is used.

The format for the DEFINE FIELD command with solely the ORDERED option and its related attributes is as follows:

Syntax

DEFINE [FIELD] name WITH [ORDERED [CHARACTER | NUMERIC] [LRESERVE n] [NRESERVE n] [SPLITPCT n] [IMMED n]]

Where:

LRESERVE defines the percentage of space to leave free on the leaf page during deferred updates or a REORGANIZE command. The default is 15 percent. The value must be between 0 and 99.
NRESERVE defines the percentage of space to leave free on the node page during deferred updates or a REORGANIZE command. The default is 15 percent. The value must be between 0 and 99.
SPLITPCT defines the percentage of the node data to go to the left node when a split occurs during nondeferred User Language or IFAM requests. The default is 50 percent. The value must be between 1 and 100.
IMMED defines the number of immediate pointers per segment in the Ordered Index. The default is 1. The value must be between 0 and 255.

Usage notes

The LRESERVE, NRESERVE, SPLITPCT, and IMMED parameters represent approximate values. The actual movement of data during an update might not conform exactly to the value of the attribute in question.

The default ordering for a field is NON-ORDERED. Ordered Index attributes do not apply for a NON-ORDERED field.

If a field is defined as ORDERED without specifying the type of tree to create, the default depends on whether the field is STRING, BINARY, or FLOAT. If STRING, an ORDERED CHARACTER tree is defined. If FLOAT or BINARY, an ORDERED NUMERIC tree is defined.

The UNIQUE attribute specifies that there can be only one occurrence of a unique field in the file. Multiple occurrences are not allowed.

For a detailed discussion of field attributes, refer to the Model 204 File Manager's Guide.

Specifying the date/time stamp field name

The new system parameter DTSFN specifies the date/time stamp field name. This field name is the same for all files participating in DTS processing in a run. Though this is a system-level parameter, the feature is a file-level feature.

The date/time stamp field name you specify is not edited for validity.

The DTSFN value may be specified in CUST source code, so you do not have to change all your jobs to specify the parameter. In the Rocket Model 204 Parameter and Command Reference see "DTSFN: Name of the date/time stamp field." As shipped, Model 204 does not provide a field name.

Specifying a date/time stamp field definition

A date/time stamp field is defined as is any other Model 204 field. The restrictions on permissible field attributes are:

  • May not be INVISIBLE or UNIQUE.

  • If preallocated, OCCURS may not be greater than 1.

Disregarding these restrictions causes the following error:

M204.2728: DATE TIME STAMP FIELD MAY NOT BE INVISIBLE, UNIQUE, NOR HAVE MULTIPLE OCCURRENCES

Rocket Software recommends using the ORDERED CHARACTER attribute. By default Model 204 generates a character string date/time stamp field value.

Defining the date/time stamp field value format

Your custom code formats the data entered into the field. The format for the default date/time stamp string is:

CCYYMMDDHHMMSSMMM

Note: The DTSFN field may have differing definitions in different Model 204 databases.