Adding records (File architecture): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==Adding a record to a file==
==Adding a record to a file==
<p>This section 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 Repeating Field Groups (RFGs) needed in this action are defined to the file. </p>
<p>This section 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>And a reminder: while fields and RFGs 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.</p>
<p>And 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.</p>


<p>The addition of the record is driven by the User Language [[Data Maintenance#STORE RECORD statement|STORE RECORD statement]] with an (optional) list of ''fieldname'' value pairs, as in the following example. </p>
<p>The addition of the record is driven by the User Language [[Data Maintenance#STORE RECORD statement|STORE RECORD statement]] with an (optional) list of ''fieldname'' value pairs, as in the following example. </p>

Revision as of 20:09, 17 July 2013

Adding a record to a file

This section 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.

And 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 User Language 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 the Rocket Model 204 User Language Manual 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 file, Model 204 is as follows:

  1. Like all User Language code, the process consists of two parts; first the code is compiled:
    1. all field names, the values of coded fields and some FRV fields are converted into fixed-length codes from Table A
    2. all other attributes of the referenced fields are noted for use during the execution
  2. Presuming the code compiles, in the evaluation process, when the STORE RECORD statement is executed:
    1. 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
    2. if there are any preallocated fields, the fields in the record map are added to the record
    3. 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. File Load Utility describes the File Load utility.