[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
DBMS Database Programming Manual


Previous Contents Index

4.5.1 Tenancy Conditions

These conditions determine whether a record in the database is an owner, or member, or a tenant in one or more sets.


set-name

is a subschema set name.

The result of the test is true if the current record of the run unit is as follows:

  • Owner of an occurrence of set-name (OWNER clause)
  • Member of an occurrence of set-name (MEMBER clause)
  • Owner or member of an occurrence of set-name (TENANT clause)

Otherwise, the result of the test is false. For example:


IF PART_USES OWNER PERFORM 100-PART-OWNER.
IF PART_USED_ON MEMBER ...
IF RESPONSIBLE_FOR TENANT ...

If NOT is used, the result of the test is reversed.

Omitting set-name allows all subschema set types in which the record participates to be considered in determining the truth value of the condition.

If the run-unit currency indicator is null, a database exception condition occurs and DB-CONDITION is set to DBM$_CRUN_NULL. If the run-unit currency indicator only specifies a position, a database exception condition occurs and DB-CONDITION is set to DBM$_CRUN_POS. See Section 4.8.3, Exception Conditions and the USE Statement for information on USE FOR DB-EXCEPTION.

4.5.2 Empty Condition

The empty condition determines whether member records are present in one or more sets. Only member record types defined in the Subschema Section are considered in determining the truth value of the condition.


set-name

is a subschema set name.

If set-name is specified, the object set is the current set of that set type. If the object set has no member records, the result of the test is true. If the object set has member records, the result of the test is false.

If set-name is not specified, the object sets, if any, are owned by the current record of the run unit whose set type is defined in the Subschema Section. If each object set has no member records, the result of the test is true. If any object set has member records, the result of the test is false. For example:


IF PART_USES EMPTY ...
IF EMPTY ...

If NOT is used, the result of the test is reversed.

A database exception condition occurs if either:

  • The currency indicator for the run unit is null (DB-CONDITION is set to DBM$_CRUN_NULL).
  • The currency indicator for the run unit specifies a position (DB-CONDITION is set to DBM$_CRUN_POS).
  • The current record of run unit is not the owner of set-name (DB-CONDITION is set to DBM$_NOTOTYP).

See Section 4.8.3, Exception Conditions and the USE Statement for information on USE FOR DB-EXCEPTION.

4.5.3 Database Key Condition

The database key condition determines whether: (1) two database key values identify the same database record, (2) a database key value is null, or (3) a database key value is identical to any database key value in a keeplist.


database-key

references a currency indicator (see section on Database Key Identifiers) or a keeplist entry in the Subschema Section.

The result of the test is true if:

  • When using the ALSO phrase, both database-keys reference identical database key values. This example compares a set currency indicator for ALL_PARTS to the currency indicator of the current record.


    IF CURRENT WITHIN ALL_PARTS IS ALSO CURRENT ...
    
  • When using the NULL phrase, the currency indicator referenced by database-key is null. This example checks the currency indicator for the current record before storing its key in a keeplist:


    IF CURRENT IS NULL NEXT SENTENCE
      ELSE
       KEEP USING KEEP-LIST-A.
    
  • When using the WITHIN phrase, any database key value in keeplist-name is identical to database-key. For example:


    IF CURRENT IS WITHIN KEEP-LIST-A
               PERFORM 200-ITS-IN-THE-LIST.
    

Otherwise, the result of the test is false.

If NOT is used, the result of the test is reversed.

A database exception condition occurs if:

  • The program identifies an invalid database key identifier. (See the Database Key Identifiers section for more information.)
  • For the NULL condition, the referenced currency indicator points to a vacant position in the database or collection:
    • Realm currency indicator (DB-CONDITION is set to DBM$_CRELM_POS).
    • Set currency indicator (DB-CONDITION is set to DBM$_CSTYP_POS).
    • Run-unit currency indicator (DB-CONDITION is set to DBM$_CRUN_POS).

    See the USE statement for more information on USE FOR DB-EXCEPTION.

4.5.4 Condition Evaluation Rules

Parentheses can specify the evaluation order in complex conditions. Conditions in parentheses are evaluated first. In nested parentheses, evaluation starts with the innermost set of parentheses. It proceeds to the outermost set.

Conditions are evaluated in a hierarchical order when there are no parentheses in a complex condition. This same order applies when all sets of parentheses are at the same level (none are nested). The hierarchy is shown in the following list:

  1. Values for arithmetic expressions
  2. Truth values for simple conditions, in this order:
    1. Relation
    2. Class
    3. Condition-name
    4. Switch-status
    5. Sign
    6. Database
    7. Success/failure
  3. Truth values for negated simple conditions
  4. Truth values for combined conditions, in this order:
    1. AND logical operators
    2. OR logical operators
  5. Truth values for negated combined conditions

In the absence of parentheses, the order of evaluation of consecutive operations at the same hierarchical level is from left to right.

4.6 Record Selection Expressions (RSE)

A record selection expression is used to select a record in the database. It can be used in a FETCH or FIND statement. The record thus selected becomes the current record of the run unit upon which subsequent statements may operate when accessing the database.

Refer also to the Oracle CODASYL DBMS Programming Guide and the Oracle CODASYL DBMS Programming Reference Manual for additional information.

General Formats

Format 1---Database Key Identifier Access

This format selects a record by a database key value held by the Database Control System (DBCS) in a currency indicator or a keeplist entry.


database-key-identifier

identifies a record according to the rules of database key identifiers. (See Section 4.4, Database Key Identifiers for more information.)

For example:


FIND CURRENT WITHIN PART-REC

Format 2---Set Owner Access

This format selects the record that owns a set.


set-name

is a subschema set name. The DBCS uses the currency indicator for set-name to choose the owner record of that set occurrence. A database exception condition occurs if set-name is a singular set (DB-CONDITION is set to DBM$_SINGTYP) or if the currency indicator for the set type is null (DB-CONDITION is set to DBM$_CSTYP_NULL).

Format 3---DB Key Access

This format selects the record that is referred to by the database key contained in the special register DB-KEY.


Format 4---Record Position Access

This format selects a record by its position within a collection of records and optionally by its record type and contents.


int-exp

is an integer or arithmetic expression resulting in a longword integer value. It cannot be zero. It may be an embedded literal or an integer data-name.

realm-name

is a subschema realm name.

record-name

is a subschema record name.

set-name

is a subschema set name.

rec-key

is a key data item within the subschema record occurrence. The same rec-key can appear only once in a given USING phrase.

bool-expression

is a conditional expression that involves data items of the object record. It is used to specify additional requirements of a qualifying record.

bool-alternate

is one or more sub-expressions (simple-bool-relation). Pairs of sub-expressions are joined by the logical operator AND.

simple-bool-relation

is a simple-condition (bool-condit), an expression, or the negation of either.

bool-condition

is a relation involving two operands joined by a relational operator.

Relational operators can be one of the following:

[NOT] EQUAL (=) TO
[NOT] LESS (<) THAN
[NOT] GREATER (>) THAN
GREATER THAN OR EQUAL (>=) TO
LESS THAN OR EQUAL (<=) TO
[NOT] CONTAIN
[NOT] CONTAINS
[NOT] MATCH
[NOT] MATCHES

The relational operator CONTAINS is used to check that a given data item in the record contains the specified string anywhere within it. At least one of the operands must be the identifier of a nondatabase item or a nonnumeric literal; the other operand must be an elementary item in the record being found or fetched.

The relational operator MATCHES checks that a given item in the records matches the specified pattern string. At least one of the operands must be the identifier of a nondatabase item or a nonnumeric literal; the other must be an elementary item in the record being found or fetched.

The pattern string is formed from any character string; however, two characters, the percent sign (%) and the asterisk (*), have special meanings. If the percent sign (%) occurs in the pattern string, it will match the current single character in the item being matched. If the asterisk (*) occurs in the pattern string, it will match any number of characters starting at the current character in the item being matched. For example:


Previous Next Contents Index