Adding records (File architecture): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (Rob moved page Adding Records Manually to Adding Records (File Architecture): tie to Table B)
m (link repair)
 
(31 intermediate revisions by 8 users not shown)
Line 1: Line 1:
==Adding a record to a file==
==Adding a record to a file==
<p>To add a record to a file: </p>
<p>
<p>Prerequisite:</p>
This page describes the process to add a record to a Model 204 file. It presumes that the file has already been [[CREATE command: File|created]] and [[INITIALIZE command|initialized]], and that all fields and field groups needed in this action are defined to the file. </p>
<p>All preallocated fields (fields that have an OCCURS clause) must be defined before any records are added to the file. </p>
<p>
<ol>
A reminder: while fields and field groups may, generally, be defined to the file at any time, some field attributes (for example, the pre-allocation of fields with the <var>OCCURS</var> attribute), may only be defined in a file to which no data has yet been added.</p>
<li>Enter a User Language STORE RECORD statement with a list of name = value pairs, as in the following example. </li>
 
</ol>
<p>
The addition of the record is driven by the SOUL <var>[[Data maintenance#STORE RECORD statement|STORE RECORD]]</var> statement with an (optional) list of ''fieldname''=''value'' pairs, as in the following example: </p>
 
<p class="code">STREC: STORE RECORD
<p class="code">STREC: STORE RECORD
   NAME=RASPUTIN
   NAME=RASPUTIN
Line 12: Line 14:
  END STORE
  END STORE
</p>
</p>
<p>Alternatively, you can use the Host Language Interface IFBREC, IFPUT, and IFSTORE functions, which also require a list of name = value pairs.</p>
<p>
<p>All field names must previously have been defined, but not all field names need to have assigned values in every record. In fact, if you omit a field, the field is not stored in the record at all, thus saving space in the file.</p>
Alternatively, you can use the Host Language Interface <var>IFBREC</var>, <var>IFPUT</var>, and <var>IFSTORE</var> calls, which also require a list of "name = value" pairs.</p>
<p>For more information see the Rocket <var class="product">Model&nbsp;204</var> User Language Manual or the Rocket <var class="product">Model&nbsp;204</var> Host Language Interface Reference Manual.</p>
<p>
<p>After records are loaded, you can add a preallocated field definition only by reinitializing the file, defining all the fields-including the new preallocated field-and reloading the records. Non-preallocated field definitions can be added at any time. </p>
All referenced field names must previously have been defined, but not all field names need to have assigned values in every record. In fact, if you omit a field, the field is not stored in the record at all, thus saving space in the file.</p>
<p>
For more information, see [[Data maintenance]] or the <var class="book">[[Media:M204 HLIReference V75.pdf|Rocket Model 204 Host Language Interface Reference Manual]]</var>.</p>
 
==How Model 204 adds records to a file==
==How Model 204 adds records to a file==
<p>In the process of adding a new record to a file, <var class="product">Model&nbsp;204</var>:</p>
<p>
The process of adding a new record to a <var class="product">Model&nbsp;204</var> file is as follows. Like all SOUL code, the process consists of two parts: </p>
<ol>
<li>The code is compiled:
<ul>
<li>All field names, the values of coded fields, and some <var>FRV</var> fields are converted into fixed-length codes from Table A. </li>
 
<li>All other attributes of the referenced fields are noted for use during the execution. </li>
</ul></li>
 
<li>In the evaluation process after compilation, when the <var>STORE RECORD</var> statement is executed:
<ul>
<li>A physical internal record number (IRN) is assigned in Table B, taking the <var>[[BRESERVE parameter|BRESERVE]]</var> parameter into account to determine if there is enough space on the page to store the record. </li>
 
<li>If there are any preallocated fields, the fields in the [[Table D (File architecture)#Record map of preallocated fields|record map]] are added to the record. </li>
 
<li>Then, for each field value pair in the <var>STORE RECORD</var> statement (none are required, an "empty" record can be created if no fields are referenced):
<ol>
<ol>
<li>Converts all field names and the values of coded fields and some FRV fields into fixed-length codes from Table A.</li>
<li>The field value pair is added to the record (for a Table E update, only the pointer is added to the field in Table B and the LOB itself is added to Table E). </li>
<li>Creates a logical <var class="product">Model&nbsp;204</var> record that contains field name = value pairs in Table B.</li>
 
<li>Adds indexing information to Tables C and D for fields that have the KEY, NUMERIC RANGE, ORDERED, or FRV field description attributes. </li>
<li>Of course, normal extension record rules apply (as discussed in [[Table B (File architecture)|Table B]] or [[Table X (File architecture)|Table X]]). </li>
 
<li>If the field is indexed, the necessary updates occur to Tables C and D. </li>
</ol></li>
</ul></li>
</ol>
</ol>
==Considerations when adding many records to a file==
==Considerations when adding many records to a file==
<p>If you are adding a large number of records to a file, consider these alternatives for increased efficiency: </p>
<p>
If you are adding a large number of records to a file, consider these alternatives for increased efficiency: </p>
<ul>
<ul>
<li>Deferred updates. Defer changes or additions that update Tables C and D, instead specifying that step 3 above be performed in separate phases. [[ Deferred Update Feature#Deferred Update Feature|Deferred Update Feature]] describes how to use deferred updates.</li>
<li>Deferred updates.  
<li>File Load utility. If the raw data for the records to be stored in the <var class="product">Model&nbsp;204</var> file already exists in a machine-readable format (magnetic tape, direct-access storage, cards), use the File Load utility to load that data directly into the <var class="product">Model&nbsp;204</var> file quickly and economically. [[ File Load Utility#File Load Utility|File Load Utility]] describes the File Load utility.</li>
<p>
Defer changes or additions that update Tables C and D, instead specifying that step 3 above be performed in separate phases. [[Deferred update feature]] describes how to use deferred updates.</p></li>
 
<li>File Load utility.  
<p>
If the raw data for the records to be stored in the <var class="product">Model&nbsp;204</var> file already exists in a machine-readable format (magnetic tape, direct-access storage, cards), use the File Load utility to load that data directly into the <var class="product">Model&nbsp;204</var> file quickly and economically. See [[File Load utility]] for more information.</p></li>
</ul>
</ul>
<p>&nbsp;</p>
[[Category:File manager]]
[[Category:File architecture]]

Latest revision as of 14:52, 23 March 2015

Adding a record to a file

This page describes the process to add a record to a Model 204 file. It presumes that the file has already been created and initialized, and that all fields and field groups needed in this action are defined to the file.

A reminder: while fields and field groups may, generally, be defined to the file at any time, some field attributes (for example, the pre-allocation of fields with the OCCURS attribute), may only be defined in a file to which no data has yet been added.

The addition of the record is driven by the SOUL STORE RECORD statement with an (optional) list of fieldname=value pairs, as in the following example:

STREC: STORE RECORD NAME=RASPUTIN SEX=MALE OCCUPATION=MONK END STORE

Alternatively, you can use the Host Language Interface IFBREC, IFPUT, and IFSTORE calls, which also require a list of "name = value" pairs.

All referenced field names must previously have been defined, but not all field names need to have assigned values in every record. In fact, if you omit a field, the field is not stored in the record at all, thus saving space in the file.

For more information, see Data maintenance or the Rocket Model 204 Host Language Interface Reference Manual.

How Model 204 adds records to a file

The process of adding a new record to a Model 204 file is as follows. Like all SOUL code, the process consists of two parts:

  1. The code is compiled:
    • All field names, the values of coded fields, and some FRV fields are converted into fixed-length codes from Table A.
    • All other attributes of the referenced fields are noted for use during the execution.
  2. In the evaluation process after compilation, when the STORE RECORD statement is executed:
    • A physical internal record number (IRN) is assigned in Table B, taking the BRESERVE parameter into account to determine if there is enough space on the page to store the record.
    • If there are any preallocated fields, the fields in the record map are added to the record.
    • Then, for each field value pair in the STORE RECORD statement (none are required, an "empty" record can be created if no fields are referenced):
      1. The field value pair is added to the record (for a Table E update, only the pointer is added to the field in Table B and the LOB itself is added to Table E).
      2. Of course, normal extension record rules apply (as discussed in Table B or Table X).
      3. If the field is indexed, the necessary updates occur to Tables C and D.

Considerations when adding many records to a file

If you are adding a large number of records to a file, consider these alternatives for increased efficiency:

  • Deferred updates.

    Defer changes or additions that update Tables C and D, instead specifying that step 3 above be performed in separate phases. Deferred update feature describes how to use deferred updates.

  • File Load utility.

    If the raw data for the records to be stored in the Model 204 file already exists in a machine-readable format (magnetic tape, direct-access storage, cards), use the File Load utility to load that data directly into the Model 204 file quickly and economically. See File Load utility for more information.