DATA INDEX DEFINITION STATEMENTS

PURPOSE:  The statements in a Data Index are of two kinds:  general statements, which apply to all domains in a Data Index, and specific statements which define each domain.  The general statements appear once and precede the definition of the domains. They must appear in the order shown below.

The use of some of the statements changes for RMS files. You must define the index type as RMS with the statement INDEX TYPE IS RMS and associate the DI to a DS with the INDEX TO DS ds.name statement.

GENERAL FORM:  General Statements

INDEX TYPE /IS/ RMS

INDEX TO ds.name

where:

INDEX TYPE /IS/ RMS

specifies that an RMS indexed storage form is associated with this Index Definition.

INDEX TO ds.name

for RMS indexed files, you must associate the Data Index to a Data Set with the same name.

GENERAL FORM: Specific Statements For Each Domain

DOMAIN name ON \\fields\\

DUPLICATES [NOT] ALLOWED

KEY CHANGE [NOT] ALLOWED

where:

DOMAIN name ON \\fields\\

names the domain and specifies the field(s) that provide the key to the domain.

RMS Indexed File Restrictions:

  1. For RMS indexed files, you must specify a primary key field in the first domain.

  2. Changes to the primary key's values need to be disallowed by using the statement KEY CHANGE NOT ALLOWED.

  3. The key fields in the domains must be the same as the primary and alternate keys in the RMS indexed files.

  4. Only the field types listed below can be used as key fields in the DOMAIN statement.

Alpha

Character

Integer (binary form only)

Date (binary form only)

Full date (binary form only)

 

When defining a multiple field domain, the fields must be of character type only. The maximum number of fields allowed in a multiple field key is eight.

DUPLICATES [NOT] ALLOWED

controls whether more than one record in the data set is allowed to have the same key field value. The default is DUPLICATES ALLOWED.

KEY CHANGE (NOT] ALLOWED

The first domain of an RMS indexed file must specify KEY CHANGE NOT ALLOWED since the first key is the primary key. This statement is not required on the other domains.

EXAMPLE

This example shows the DI definition for an RMS file called PHONE.RMS.

*DEFINE DI PHONE.RMS. ENTRY ONLY
--10 INDEX TYPE IS RMS
--20 INDEX TO PHONE.RMS
--30 DOMAIN NAME ON NAME
--40 KEY CHANGE NOT ALLOWED
--SAVE

USE DS

PURPOSE:  The USE DS command declares a Data Set upon which subsequent commands operate. In the case of RMS indexed Data Sets, the DI must be declared at the same time.

GENERAL FORM

USE DS ds.name [ALWAYS] [DI di.name]

where:

USE DS ds.name

declares the Data Set to be used.

DI di.name

specifies the Data Index for the declared Data Set. This is required for RMS indexed files and may be entered as part of the USE DS command or in the USE DI command.

ALWAYS

must be used if the RMS indexed file does not currently exist. This creates the associated system file that informs ACCENT R that the file might not currently exist, but to proceed as if it did. It does not check that the file currently exists.

EXAMPLE

*USE DS PHONE.RMS ALWAYS DI PHONE.RMS

ENTER

PURPOSE:  The ENTER command creates new records in the current data set from the terminal or from an unformatted systems file. There is one change in the use of the NEW clause when ENTER is used with RMS indexed files.

GENERAL FORM

ENTER [NEW]

where:

[NEW]

clears all records from the current Data Set.  You must use the NEW clause if the file does not currently exist.  Otherwise, ACCENT R assumes that the file is there and attempts to append to it.

GET STATEMENT

PURPOSE:  The record retrieval form of the GET statement is used to retrieve records from an auxiliary Data Set through the RMS index. Records can be retrieved sequentially or by key value.  A GET statement can only retrieve from an RMS indexed file in a forward direction. GET LAST, GET PRIOR, GET LOW... FIT, GET LAST... FIT, GET PRIOR... MATCH BY, and GET LAST... MATCH BY cannot be used.

GENERAL FORM

GET FROM designator

[/USE/ DOMAIN name]

retrieval method

[HUSH]

[IF; UNLESS clause]

where:

FROM designator

specifies the name related to an RMS index by the RELATE declaration. The FROM designator may appear immediately after the GET or before the HUSH.

[/USE/ DOMAIN name]

specifies the name of the domain to be used. If there are multiple domains and this clause is not specified, the first domain is used. This option may appear immediately before or after the FROM designator clause.

This option allows the GET statement to easily access the Data Set using multiple domains. Records can be retrieved in multiple sequences and by different key fields. The logical order of the Data Set may be changed by changing the domain. When the domain is changed, ACCENT R retrieves records starting from the beginning of the logical order of the new domain.

retrieval method

specifies the method to retrieve records (see forms 1-3 on the following pages). The methods are:

  • Sequential Access (Form 1) retrieves records sequentially in ascending order only. The first logical record of the Data Set can also be retrieved.

  • Key Matching Access (Form 2) retrieves a record by its key field value.

  • Key Range Access (Form 3) retrieves a record by its key field value, but if not found, retrieves the record with the next higher key field value.

FORM 1: Sequential Access

GET FROM designator (FIRST; NEXT) /RECORD/ [/USE/ DOMAIN name]

[IF;UNLESS clause]

[HUSH]

where:

FROM designator and [/USE/ DOMAIN name]

are as described for the General Form.

FIRST /RECORD/

retrieves the first logical record of the specified domain or the first domain if none is specified.

NEXT /RECORD/

sequentially retrieves the next record from the Data Set. The order of the records is the logical order of the specified domain. If no previous GET has been used for the Data Set or if the domain has changed, GET FIRST is performed.

FORM 2: Key Matching Access

GET FROM designator (FIRST; NEXT) MATCH /RECORD/ BY \\values\\

[/USE/ DOMAIN name]

[HUSH]

[IF;UNLESS clause]

where:

FROM designator and [/USE/ DOMAIN name]    are as described for the General Form.

MATCH /RECORD/

retrieves a record with the specified key field value. ACCENT R searches for a record that has the same key field value as that specified in the BY \\values\\ clause. The first record of a group of matching records is always retrieved unless NEXT is specified.

FIRST MATCH /RECORD/

retrieves the first record of a group of records with the same specified key field value. FIRST MATCH /RECORD/ is the default for indexed retrieval.

NEXT MATCH /RECORD/

sequentially retrieves the next record from the Data Set that has the specified key field value. The order of the records is the logical order of the specified domain. GET FIRST MATCH is performed if the last GET statement failed, if no previous GET has been used for the Data Set, or if the domain has changed.

BY \\values\\

specifies the key field values used in all matching operations. \\values\\ may contain a list of literals, constants, fields, expressions, or functions, as long as they evaluate to the appropriate field types. For the related DI, the values must correspond to the fields specified in the ON \\fields\\ clause of the specified domain.

FORM 3: Key Range Access

GET FROM designator (HIGH; FIRST HIGH) FIT /RECORD/ BY \\values\\

[/USE/ DOMAIN name][

[HUSH]

[IF;UNLESS clause]

where:

FROM designator and [/USE/ DOMAIN name]

are as described for the General Form.

HIGH FIT /RECORD/

retrieves a record with the specified key field value or, if a record with the specified key field value does not exist, sequentially retrieves the first subsequent record whose key field value is greater than the specified key field value. ACCENT R searches for a record whose key field value is greater than or equal to that specified in the BY \\values\\ clause.

FIRST HIGH FIT /RECORD/

is exactly the same as HIGH FIT.

BY \\values\\

is as described for Form 2.

RELATE STATEMENTS

PURPOSE:  When an RMS indexed file is declared, a DI or an ID must be related for the Data Set. Because an RMS indexed file contains both the data and the data index, relating a Data Set or the Schema Definition is not allowed.

EXAMPLES

The examples below show a DI and an ID named PHONE.RMS declared for use in the Process Module named PHONE.UPD.

*DEFINE PM PHONE.UPD
--10 CONTROL SECTION
--20 RELATE DI PHONE.RMS AS PL
*DEFINE PM PHONE.UPD
--10 CONTROL SECTION
--20 RELATE ID PHONE.RMS AS PL