DEFINE FIELD command: Difference between revisions
(Automatically generated page update) |
(→Syntax) |
||
Line 87: | Line 87: | ||
<tr> <th>This attribute...</th> <th>Must be specified with the attribute(s)...</th> </tr> | <tr> <th>This attribute...</th> <th>Must be specified with the attribute(s)...</th> </tr> | ||
<tr> <th><var>CONCATENATION-OF</var></th> <td>AT-MOST-ONE or EXACTLY-ONE or OCCURS 1</td> </tr> | |||
<tr> <th><var>COUNT-OCCURRENCES-OF</var></th> <td>AT-MOST-ONE or EXACTLY-ONE or OCCURS 1</td> </tr> | |||
<tr> <th><var>CREATE-TIME</var></th> <td>AT-MOST-ONE</td> </tr> | |||
<tr> <th><var>CREATE-TIMEUTC</var></th> <td>AT-MOST-ONE</td> </tr> | |||
<tr> <th><var>DEFAULT-VALUE</var></th> <td>AT-MOST-ONE or EXACTLY-ONE</td> </tr> | |||
<tr> <th><var>ESCAPE</var></th> <td>CONCATENATION-OF</td> </tr> | |||
<tr> <th><var>FEW-VALUED</var></th> <td>FRV or CODED</td> </tr> | |||
<tr> <th><var>FLOAT</var></th> <td>LENGTH</td> </tr> | <tr> <th><var>FLOAT</var></th> <td>LENGTH</td> </tr> | ||
<tr> <th><var>MANY-VALUED</var></th> <td>FRV or CODED</td> </tr> | |||
<tr> <th><var>MINLOBE</var></th> <td>BINARY LARGE OBJECT or CHARACTER LARGE OBJECT</td> </tr> | |||
<tr> <th><var>OCCURS</var></th> <td>CODED, BINARY, or LENGTH</td> </tr> | <tr> <th><var>OCCURS</var></th> <td>CODED, BINARY, or LENGTH</td> </tr> | ||
<tr> <th><var>PAD</var></th> <td>LENGTH</td> </tr> | <tr> <th><var>PAD</var></th> <td>LENGTH</td> </tr> | ||
<tr> <th><var>SEPARATOR</var></th> <td>CONCATENATION-OF</td> </tr> | |||
<tr> <th><var>STORE-DEFAULT</var></th> <td>DEFAULT-VALUE, AT-MOST-ONE, or EXACTLY-ONE</td> </tr> | |||
<tr> <th><var>UNIQUE</var></th> <td>ORDERED</td> </tr> | <tr> <th><var>UNIQUE</var></th> <td>ORDERED</td> </tr> | ||
<tr> <th><var>UPDATE-TIME</var></th> <td>AT-MOST-ONE</td> </tr> | |||
<tr> <th><var>UPDATE-TIMEUTC</var></th> <td>AT-MOST-ONE</td> </tr> | |||
<tr> <th><var>UNIQUE</var></th> <td>ORDERED</td> </tr> | |||
</table> | </table> | ||
===Syntax notes=== | ===Syntax notes=== | ||
<p>Attributes must be separated by commas or by one or more blanks.</p> | <p>Attributes must be separated by commas or by one or more blanks.</p> | ||
<p>You can specify DEFINE FIELD only in file context.</p> | <p>You can specify DEFINE FIELD only in file context.</p> | ||
==Example== | ==Example== | ||
<p class="code">DEFINE FIELD CUSTID WITH KEY FRV RANGE | <p class="code">DEFINE FIELD CUSTID WITH KEY FRV RANGE |
Revision as of 21:36, 24 June 2013
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.
|
Conflicting attributes, listed in the table below, cannot be specified together.
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.
This attribute... | Must be specified with the attribute(s)... |
---|---|
CONCATENATION-OF | AT-MOST-ONE or EXACTLY-ONE or OCCURS 1 |
COUNT-OCCURRENCES-OF | AT-MOST-ONE or EXACTLY-ONE or OCCURS 1 |
CREATE-TIME | AT-MOST-ONE |
CREATE-TIMEUTC | AT-MOST-ONE |
DEFAULT-VALUE | AT-MOST-ONE or EXACTLY-ONE |
ESCAPE | CONCATENATION-OF |
FEW-VALUED | FRV or CODED |
FLOAT | LENGTH |
MANY-VALUED | FRV or CODED |
MINLOBE | BINARY LARGE OBJECT or CHARACTER LARGE OBJECT |
OCCURS | CODED, BINARY, or LENGTH |
PAD | LENGTH |
SEPARATOR | CONCATENATION-OF |
STORE-DEFAULT | DEFAULT-VALUE, AT-MOST-ONE, or EXACTLY-ONE |
UNIQUE | ORDERED |
UPDATE-TIME | AT-MOST-ONE |
UPDATE-TIMEUTC | AT-MOST-ONE |
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.
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.