INITIALIZE command

From m204wiki
Jump to navigation Jump to search

Summary

Privileges
File manager
Function
Clears the data while preserving the structure of an open Model 204 file

Syntax

In the first form of the INITIALIZE command, the optional SORT | HASH and RECSCTY specifications are specified on one or two separate lines, after the line with the INITIALIZE command proper:

[IN filename] INITIALIZE [{SORT | HASH} fieldDefinition] [RECSCTY fieldDefinition]

Or:

[IN filename] INITIALIZE KEEPDEF[S]


Where:

  • Caution: Although the IN filename clause is optional, it is strongly recommended that you employ this on every INITIALIZE command, especially any entered from the terminal, to avoid initializing - and so destroying all contents of - some unintended file that happens to be the current default.

  • KEEPDEFS specifies that INITIALIZE processing retain the field definitions when issued on a file that has defined fields. With the KEEPDEFS option, INITIALIZE processing will not format Table A attribute pages. The KEEPDEFS argument is entered on the INITIALIZE command line.

    If KEEPDEFS is specified on the INITIALIZE command line, then the INITIALIZE processing verifies the presence of the sort or hash and/or record security fields, if specified by the FILEORG and/or OPENCTL parameters. In this case, the file manager cannot define or redefine those fields.

    If KEEPDEFS is not specified, and the FILEORG creation parameter defines the file to be either HASH or SORT and/or the OPENCTL parameter defines the file to be a record security file, then additional input lines follow the INITIALIZE command line. One line defines the field to be used as the hash or sort key and one line defines the field to be used as a record security key. Those two lines may be in either order.

  • SORT or HASH, which are mutually exclusive, specifies that the fieldDefinition that follows is a key field on which the file is sorted or on which a hash key is specified. SORT or HASH is required, if the FILEORG parameter defined the file SORT or HASH. The sort or hash field need not be defined with the Model 204 field attribute KEY.

  • RECSCTY specifies that the fieldDefinition that follows is for the record security key of a record security file. If the OPENCTL parameter defines the file as a record security file, the RECSCTY clause is mandatory. The INITIALIZE process automatically defines any record security field to have the Model 204 attribute of KEY.
  • fieldDefinition is a definition of the SORT, HASH, or record security field in the Model 204 file. It is specified in the form:

    fieldname [ (attribute [, attribute ,...]) ]

    In the fieldDefinition, attributes must be separated by commas or blanks and must be enclosed in parentheses. The other rules for specifying field names and attributes are presented in DEFINE FIELD command and are discussed in detail in Field design.

Usage notes

  • Caution: Although the IN filename clause is optional, it is strongly recommended that you employ this on every INITIALIZE command, especially any entered from the terminal, to avoid initializing - and so destroying all contents of - some unintended file that happens to be the current default.

  • The INITIALIZE command must be issued in file context: that is, the IN clause must specify a file, not a group (or if, against recommendations, you do not use an IN clause, the current default - e.g., following the OPEN command for the file - must be a file, not a group).

  • If the file already has data in it, the data is erased; however, parameter settings for the file are preserved.

    However, if the KEEPDEFS option was also specified, the field definitions are preserved along with the parameter settings.

  • To use the INITIALIZE command you must have update authority to the selected file. If the file is open for read-only access, the INITIALIZE command is rejected with the following message:

    M204.1036: UPDATES NOT PERMITTED.

Specifying mandatory INITIALIZE options

You must specify the appropriate option(s) on the following types of file:

  • For a sort file, you must specify the SORT option before field-description.

  • For a hash file, you must specify the HASH option before field-description.

  • For a file with record security in effect, you must specify the RECSCTY option before field-description.

The order of the options is unimportant. A full description of different Model 204 file types is included in Specifying a file organization.

Specifying field attributes

For sort or hash key fields, Model 204 automatically supplies the following field attributes as though you had entered them:

(NON-CODED STRING VISIBLE)

For hash key fields, Model 204 also supplies the NON-KEY attribute as though you had entered them as follows:

(NON-CODED STRING VISIBLE NON-KEY)

Neither sort nor hash key fields can have the UPDATE attribute.

If a sort or hash key is required in every record, you can specify the OCCURS 1 attribute. If a key is not required, do not specify the OCCURS attribute.

For record security fields, the KEY attribute is automatically supplied.

The following example code illustrates when a hash or sort key file or a record security file is initialized:

OPEN filename *** M204.0620: FILE filename OPENED *** M204.0627: FILE filename IS NOT INITIALIZED INITIALIZE *** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY

When Model 204 processes the INITIALIZE command, Model 204 ends any update unit in progress and begins a non-backoutable update unit.

Keeping field definitions

KEEPDEFS processing happens only on a file that has fields defined. If you specify the KEEPDEFS option, but no field name definitions are associated with the file, the following message is issued. Processing continues as though the option had not been specified. File pages-including Table A, MANY-VALUED, and FEW-VALUED pages-are formatted as they are when KEEPDEFS is not specified.

M204.2646 'KEEPDEFS' SPECIFIED AND NO FIELD DEFINITIONS PRESENT, 'KEEPDEFS' IGNORED

If KEEPDEFS processing ends with one of the following variations of message M204.2645, the file remains as it was before the INITIALIZE KEEPDEFS command was issued. The possible variations are:

M204.2645 'KEEPDEFS' SPECIFIED AND SOME FIELD DEFINITION PAGES ARE UNREADABLE M204.2645 'KEEPDEFS' SPECIFIED AND FIELD DEFINITION PAGES NOT PREVIOUSLY INITIALIZED M204.2645 'KEEPDEFS' SPECIFIED AND THE NECESSARY SORT/HASH/RECORD FIELD(S) ARE NOT PRESENT

Note: The previous message, M204.2646, is never issued for a SORT, HASH, or RECSCTY file; for those types of files, only message M204.2645 can be issued.

Completion of an INITIALIZE KEEPDEFS command ends with the message:

M204.0764 END FILE INITIALIZATION: <filename> - FIELD DEFINITIONS PRESERVED

Limitation to INITIALIZE KEEPDEFS

You cannot use an INITIALIZE KEEPDEFS command to recover deleted space in the Table A attribute pages; it merely skips formatting those pages.

Examples

OPEN CARS *** M204.0620: FILE CARS OPENED *** M204.0627: CARS IS NOT INITIALIZED IN CARS INITIALIZE *** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY SORT SERIAL NUMBER (OCCURS 1 LENGTH 10) *** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY RECSCTY RECSEC OPEN TESTFILE *** M204.0620: FILE TESTFILE OPENED *** M204.0627: TESTFILE IS NOT INITIALIZED IN TESTFILE INITIALIZE KEEPDEFS *** M204.0763: BEGIN FILE INITIALIZATION: TESTFILE *** M204.0764: END FILE INITIALIZATION: TESTFILE - FIELD DEFINITIONS PRESERVED