INITIALIZE command: Difference between revisions
(→Syntax) |
|||
Line 9: | Line 9: | ||
==Syntax== | ==Syntax== | ||
<p class="syntax"><span class="squareb">[</span><span class="literal">IN</span> <span class="term">filename</span><span class="squareb">]</span> <span class="literal">INITIALIZE</span> | <p class="syntax"><span class="squareb">[</span><span class="literal">IN</span> <span class="term">filename</span><span class="squareb">]</span> <span class="literal">INITIALIZE</span> | ||
<span class="squareb">[</span> <span class="literal">SORT</span><span class="squareb">|</span><span class="literal">HASH</span> <span class="term" | <span class="squareb">[{</span><span class="literal">SORT</span> <span class="squareb">|</span> <span class="literal">HASH</span><span class="term"><span class="squareb">} </span>fieldDefinition</span><span class="squareb">]</span> | ||
<span class="squareb">[</span> <span class="literal">RECSCTY</span> <span class="term"> | <span class="squareb">[</span><span class="literal">RECSCTY</span> <span class="term">fieldDefinition</span><span class="squareb">]</span> </p> | ||
Or: | Or: | ||
Line 16: | Line 16: | ||
<p class="syntax"><span class="squareb">[</span><span class="literal">IN</span> <span class="term">filename</span><span class="squareb">]</span> <span class="literal">INITIALIZE</span> <span class="literal">KEEPDEF</span><span class="squareb">[</span><span class="literal">S</span><span class="squareb">]</span> | <p class="syntax"><span class="squareb">[</span><span class="literal">IN</span> <span class="term">filename</span><span class="squareb">]</span> <span class="literal">INITIALIZE</span> <span class="literal">KEEPDEF</span><span class="squareb">[</span><span class="literal">S</span><span class="squareb">]</span> | ||
</p> | </p> | ||
Where: | Where: | ||
<ul> | |||
<ul> | |||
<li><var>KEEPDEFS </var>specifies that <var>INITIALIZE</var> processing retain the field definitions when issued on a file that has defined fields. With the <var>KEEPDEFS</var> option, <var>INITIALIZE</var> processing will not format Table A attribute pages. The <var>KEEPDEFS</var> argument is entered on the <var>INITIALIZE</var> command line. | <li><var>KEEPDEFS </var>specifies that <var>INITIALIZE</var> processing retain the field definitions when issued on a file that has defined fields. With the <var>KEEPDEFS</var> option, <var>INITIALIZE</var> processing will not format Table A attribute pages. The <var>KEEPDEFS</var> argument is entered on the <var>INITIALIZE</var> command line. | ||
<p> | <p> | ||
If <var>KEEPDEFS</var> is specified on the <var>INITIALIZE</var> command line, then the <var>INITIALIZE</var> processing verifies the presence of the sort or hash and/or record security fields, if specified by the <var>[[FILEORG parameter|FILEORG]]</var> and/or <var>[[OPENCTL parameter|OPENCTL]]</var> parameters. In this case, the file manager cannot define or redefine those fields.</p> | If <var>KEEPDEFS</var> is specified on the <var>INITIALIZE</var> command line, then the <var>INITIALIZE</var> processing verifies the presence of the sort or hash and/or record security fields, if specified by the <var>[[FILEORG parameter|FILEORG]]</var> and/or <var>[[OPENCTL parameter|OPENCTL]]</var> parameters. In this case, the file manager cannot define or redefine those fields.</p> | ||
<p> | <p> | ||
If <var>KEEPDEFS</var> is not specified, and the <var>FILEORG</var> creation parameter defines the file to be either <var>HASH</var> or <var>SORT</var> and/or the <var>OPENCTL</var> parameter defines the file to be a record security file, then additional input lines follow the <var>INITIALIZE</var> 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. | If <var>KEEPDEFS</var> is not specified, and the <var>FILEORG</var> creation parameter defines the file to be either <var>HASH</var> or <var>SORT</var> and/or the <var>OPENCTL</var> parameter defines the file to be a record security file, then additional input lines follow the <var>INITIALIZE</var> 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.</p></li> | ||
<li><var>SORT</var> or <var>HASH</var>, which are mutually exclusive, specifies that the <var class="term">fieldDefinition</var> that follows is a key field on which the file is sorted or on which a hash key is specified. <var>SORT</var> or <var>HASH</var> is required, if the <var>FILEORG</var> parameter defined the file <var>SORT</var> or <var>HASH</var>. The sort or hash field need not be defined with the <var class="product">Model 204</var> field attribute <var>KEY</var>. | |||
<p></p> | |||
</li> | |||
<li><var>RECSCTY</var> specifies that the | <li><var>RECSCTY</var> specifies that the <var class="term">fieldDefinition</var> that follows is for the record security key of a record security file. If the <var>OPENCTL</var> parameter defines the file as a record security file, the <var>RECSCTY</var> clause is mandatory. The <var>INITIALIZE</var> process automatically defines any record security field to have the <var class="product">Model 204</var> attribute of <var>KEY</var>.</li> | ||
<li><var class="term"> | <li><var class="term">fieldDefinition</var> is a definition of the <var>SORT</var>, <var>HASH</var>, or record security field in the <var class="product">Model 204</var> file. It is specified in the form: | ||
<p class=" | <p class="syntax"><span class="term">fieldname</span> <span class="squareb">[</span> (<span class="term">attribute</span> <span class="squareb">[</span>, <span class="term">attribute</span> ,<span class="squareb">...</span>]) <span class="squareb">]</span> | ||
</p> | </p> | ||
<p> | <p> | ||
In the | In the <var class="term">fieldDefinition</var>, 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]].</p></li> | ||
</ul> | </ul> | ||
Revision as of 12:43, 30 November 2017
Summary
- Privileges
- File manager
- Function
- Clears the data while preserving the structure of an open Model 204 file
Syntax
[IN filename] INITIALIZE [{SORT | HASH} fieldDefinition] [RECSCTY fieldDefinition]
Or:
[IN filename] INITIALIZE KEEPDEF[S]
Where:
- 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
You must issue an INITIALIZE command in file context: that is, the current default must be a file, not a group, following the OPEN command for the file.
-
If the file already has data in it, the data is erased; however, parameter settings for the file are preserved.
-
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