INITIALIZE command: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Automatically generated page update)
 
 
(8 intermediate revisions by 3 users not shown)
Line 6: Line 6:
<dd>Clears the data while preserving the structure of an open <var class="product">Model&nbsp;204</var> file
<dd>Clears the data while preserving the structure of an open <var class="product">Model&nbsp;204</var> file
</dl>
</dl>
==Syntax==
==Syntax==
<p class="syntax">INITIALIZE [KEEPDEFS]  
In the first form of the <var>INITIALIZE</var> command, the optional <var>SORT</var> | <var>HASH</var> and <var>RECSCTY</var> specifications are specified on one or two separate lines, after the line with the <var>INITIALIZE</var> command proper:
  [RECSCTY field-description]
<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>
  [[SORT | HASH] field-description]  
<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">fieldDefinition</span><span class="squareb">]</span> </p>
Or:
<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>
   
   
<b>Where:</b>
<ul>
<li>
<p><var>KEEPDEFS </var>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.</p>
<ul>
<li>
<p>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.</p>
</li>
   
   
<li>
Where:
<p>If the 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. The field-description lines may be in either order.</p>
</li>
<ul>
  </ul>
<li><b>Caution:</b> Although the <code>[[Overview of Model 204 commands#inClause|IN filename]]</code> clause is optional, it is strongly recommended that you employ this on every INITIALIZE command, <b>especially</b> any entered from the terminal, to avoid initializing - and so destroying all contents of - some unintended file that happens to be the current default.
<p></p></li>
<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>
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>
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&nbsp;204</var> field attribute <var>KEY</var>.
<p></p>
</li>
</li>
   
   
<li>
<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&nbsp;204</var> attribute of <var>KEY</var>.</li>
<p>RECSCTY specifies that the field-description that follows is a record security file. If the OPENCTRL 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 <var class="product">Model&nbsp;204</var> attribute of KEY.</p>
</li>
   
   
<li>
<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&nbsp;204</var> file. It is specified in the form:
<p>field-description is a description of a field in the <var class="product">Model&nbsp;204</var> file. It is specified in the form:</p>
<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 class="code"><i>fieldname</i> (<i>attribute</i> [,<i>attribute</i>...])]
</p>
</p>
<p>In the field-description, 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 the description of the DEFINE command and are discussed in detail in the <var>Model&nbsp;204 File Manager's Guide</var>.</p>
<p>
</li>
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>
<li>
 
<p><var>SORT</var> or <var>HASH</var>, which are mutually exclusive, specifies that the filed-description 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 <var class="product">Model&nbsp;204</var> field attribute KEY.</p>
</li>
</ul>
==Usage notes==
==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.  
<ul>
<ul>  
<li><b>Caution:</b> Although the <code>[[Overview of Model 204 commands#inClause|IN filename]]</code> clause is optional, it is strongly recommended that you employ this on every INITIALIZE command, <b>especially</b> any entered from the terminal, to avoid initializing - and so destroying all contents of - some unintended file that happens to be the current default.
<p></p></li>
 
<li>The <var>INITIALIZE</var> command must be issued in file context: that is, the <code>IN</code> clause must specify a file, not a group (or if, against recommendations, you do not use an <code>IN</code> clause, the current default - e.g., following the OPEN command for the file - must be a file, not a group).  
<p></p></li>
 
<li>
<li>
<p>If the file already has data in it, the data is erased; however, parameter settings for the file are preserved.</p>
<p>If the file already has data in it, the data is erased; however, parameter settings for the file are preserved.</p>
</li>
 
<p>However, if the <var>KEEPDEFS</var> option was also specified, the field definitions are preserved along with the parameter settings.
</p></li>
 
<li>
<li>
<p>If the KEEPDEFS option was also specified, the field definitions are preserved along with the parameter settings.</p>
To use the <var>INITIALIZE</var> command you must have update authority to the selected file. If the file is open for read-only access, the <var>INITIALIZE</var> command is rejected with the following message:
</li>
</ul>
<p>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: </p>
<p class="code">M204.1036: UPDATES NOT PERMITTED.
<p class="code">M204.1036: UPDATES NOT PERMITTED.
</p>
</p>
====Specifying INITIALIZE options-optional, but mandatory====
</li>
<p>You must specify the appropriate option(s) on the following types of file: </p>
</ul>
 
====Specifying mandatory INITIALIZE options====
<p>
You must specify the appropriate option(s) on the following types of file: </p>
<ul>  
<ul>  
<li>
<li>
<p>For a sort file, you must specify the SORT option before field- description. </p>
<p>For a sort file, you must specify the <var>SORT</var> option before field-description. </p>
</li>
</li>
   
   
<li>
<li>
<p>For a hash file, you must specify the HASH option before field-description. </p>
<p>For a hash file, you must specify the <var>HASH</var> option before field-description. </p>
</li>
</li>
   
   
<li>
<li>
<p>For a file with record security in effect, you must specify the RECSCTY option before field-description. </p>
<p>For a file with record security in effect, you must specify the <var>RECSCTY</var> option before field-description. </p>
</li>
</li>
</ul>
</ul>
<p>The order of the options is unimportant. A full description of different <var class="product">Model&nbsp;204</var> file types is included in the <var>Model&nbsp;204 File Manager's Guide.</var></p>
<p>
The order of the options is unimportant. A full description of different <var class="product">Model&nbsp;204</var> file types is included in [[File design#Specifying a file organization|Specifying a file organization]].</p>
 
====Specifying field attributes====
====Specifying field attributes====
<p>For sort or hash key fields, <var class="product">Model&nbsp;204</var> automatically supplies the following field attributes as though you had entered them:</p>
<p>
For sort or hash key fields, <var class="product">Model&nbsp;204</var> automatically supplies the following field attributes as though you had entered them:</p>
<p class="code">(NON-CODED STRING VISIBLE)
<p class="code">(NON-CODED STRING VISIBLE)
</p>
</p>
For hash key fields, <var class="product">Model&nbsp;204</var> also supplies the NON-KEY attribute as though you had entered them as follows:  
For hash key fields, <var class="product">Model&nbsp;204</var> also supplies the <var>NON-KEY</var> attribute as though you had entered them as follows:  
<p class="code">(NON-CODED STRING VISIBLE NON-KEY)
<p class="code">(NON-CODED STRING VISIBLE NON-KEY)
</p>
</p>
<p>Neither sort nor hash key fields can have the UPDATE attribute. </p>
<p>
<p>If a sort or hash key is required in every record, you can specify the OCCURS&nbsp;1 attribute. If a key is not required, do not specify the OCCURS attribute. </p>
Neither sort nor hash key fields can have the <var>UPDATE</var> attribute. </p>
<p>For record security fields, the KEY attribute is automatically supplied.</p>
<p>
<p>The following example code illustrates when a hash or sort key file or a record security file is initialized:</p>
If a sort or hash key is required in every record, you can specify the OCCURS&nbsp;1 attribute. If a key is not required, do not specify the OCCURS attribute. </p>
<p>
For record security fields, the <var>KEY</var> attribute is automatically supplied.</p>
<p>
The following example code illustrates when a hash or sort key file or a record security file is initialized:</p>
<p class="code"><b>OPEN filename</b>
<p class="code"><b>OPEN filename</b>
<b></b>*** M204.0620: FILE filename OPENED
<b></b>*** M204.0620: FILE filename OPENED
Line 89: Line 105:
<b></b>*** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY
<b></b>*** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY
</p>
</p>
<p>When <var class="product">Model&nbsp;204</var> processes the INITIALIZE command, <var class="product">Model&nbsp;204</var> ends any update unit in progress and begins a non-backoutable update unit. For more information about <var class="product">Model&nbsp;204</var> update units, see "<var class="product">Model&nbsp;204</var> update units" in the <var class="product">Model&nbsp;204</var> File Manager's Guide.</p>
<p>
When <var class="product">Model&nbsp;204</var> processes the <var>INITIALIZE</var> command, <var class="product">Model&nbsp;204</var> ends any [[File integrity and recovery#Update units and transactions|update unit]] in progress and begins a non-backoutable update unit. </p>
 
====Keeping field definitions====
====Keeping field definitions====
<p>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. </p>
<p>
<var>KEEPDEFS</var> processing happens only on a file that has fields defined. If you specify the <var>KEEPDEFS</var> 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 <var>KEEPDEFS</var> is not specified. </p>
<p class="code">M204.2646 'KEEPDEFS' SPECIFIED AND NO FIELD DEFINITIONS PRESENT, 'KEEPDEFS' IGNORED
<p class="code">M204.2646 'KEEPDEFS' SPECIFIED AND NO FIELD DEFINITIONS PRESENT, 'KEEPDEFS' IGNORED
</p>
</p>
<p>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: </p>
<p>
If <var>KEEPDEFS</var> processing ends with one of the following variations of message M204.2645, the file remains as it was before the <code>INITIALIZE KEEPDEFS</code> command was issued. The possible variations are: </p>
<p class="code">M204.2645 'KEEPDEFS' SPECIFIED AND SOME FIELD DEFINITION PAGES ARE UNREADABLE
<p class="code">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 FIELD DEFINITION PAGES NOT PREVIOUSLY INITIALIZED  
Line 100: Line 120:
</p>
</p>
<p class="note"><b>Note:</b> 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.</p>
<p class="note"><b>Note:</b> 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.</p>
<p>Completion of an INITIALIZE KEEPDEFS command ends with the message: </p>
<p>
<p class="code">M204.0764 END FILE INITIALIZATION: &lt;filename> - FIELD DEFINITIONS PRESERVED
Completion of an <code>INITIALIZE KEEPDEFS</code> command ends with the message: </p>
<p class="code">M204.0764 END FILE INITIALIZATION: <filename> - FIELD DEFINITIONS PRESERVED
</p>
</p>
====Limitation to INITIALIZE KEEPDEFS====
====Limitation to INITIALIZE KEEPDEFS====
<p>You cannot use an INITIALIZE KEEPDEFS command to recover deleted space in the Table A attribute pages; it merely skips formatting those pages.</p>
<p>
You cannot use an <code>INITIALIZE KEEPDEFS</code> command to recover deleted space in the Table A attribute pages; it merely skips formatting those pages.</p>
 
==Examples==
==Examples==
<p class="code"><b>OPEN CARS</b>
<p class="code"><b>OPEN CARS</b>
<b></b>*** M204.0620: FILE CARS OPENED
<b></b>*** M204.0620: FILE CARS OPENED
<b></b>*** M204.0627: CARS IS NOT INITIALIZED  
<b></b>*** M204.0627: CARS IS NOT INITIALIZED  
<b>INITIALIZE</b>
<b>IN CARS INITIALIZE</b>
<b></b>*** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY
<b></b>*** M204.0765: ENTER SORT, HASH, OR RECORD SECURITY KEY
SORT SERIAL NUMBER (OCCURS 1 LENGTH 10)
SORT SERIAL NUMBER (OCCURS 1 LENGTH 10)
Line 117: Line 141:
</b>*** M204.0620: FILE TESTFILE OPENED
</b>*** M204.0620: FILE TESTFILE OPENED
<b></b>*** M204.0627: TESTFILE IS NOT INITIALIZED  
<b></b>*** M204.0627: TESTFILE IS NOT INITIALIZED  
<b>INITIALIZE KEEPDEFS</b>
<b>IN TESTFILE INITIALIZE KEEPDEFS</b>
<b></b>*** M204.0763: BEGIN FILE INITIALIZATION: TESTFILE
<b></b>*** M204.0763: BEGIN FILE INITIALIZATION: TESTFILE
<b></b>*** M204.0764: END FILE INITIALIZATION: TESTFILE - FIELD DEFINITIONS PRESERVED  
<b></b>*** M204.0764: END FILE INITIALIZATION: TESTFILE - FIELD DEFINITIONS PRESERVED  
</p>
</p>
[[Category: File manager commands]]
[[Category: File manager commands]]
[[Category:Commands]]
[[Category:Commands]]

Latest revision as of 14:32, 21 February 2019

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