[an error occurred while processing this directive]

HP OpenVMS Systems Documentation

Content starts here

HP COBOL
DBMS Database Programming Manual


Previous Contents Index


RECONNECT

Function

The RECONNECT statement moves the current database record of the run unit from one set to another (possibly the same) set.


record-name

names a subschema record type.

set-name

names a subschema set type.

stment

is an imperative statement executed for an on error condition.

stment2

is an imperative statement executed for a not on error condition.

Syntax Rules

  1. The record type of record-name must be a member record type of the set type for each set-name.
  2. Set-name cannot be specified more than once in the WITHIN clause.
  3. Set-name cannot be specified more than once in the RETAINING clause.

General Rules

  1. RECONNECT uses the current record of the run unit.
  2. The current run unit record must be in a realm in ready update mode and all records required by the Database Control System (DBCS) to execute the RECONNECT statement must be in realms in available mode.
  3. Use record-name to check that the record type of the current record of the run unit is identical to the record type specified by record-name.
  4. For each set-name you specify in the WITHIN clause:
    1. The DBCS disconnects the current record of the run unit from the set in which it is currently a member and inserts this record in the current set of the set-name set type.
    2. The position where the DBCS inserts the record into the set is determined by the set-ordering criteria defined in the schema for set-name.
  5. If the program specifies the ALL option:
    1. The DBCS considers only those set types that satisfy these requirements:
      • The set type is in your subschema.
      • The current run-unit record type is defined in the schema as an OPTIONAL or MANDATORY member record type of the set type.
      • The current run-unit record is presently a member of a set of the set type.
    2. For each selected set type:
      • The DBCS disconnects the current record of the run unit from the set in which it is currently a member and inserts this record in the current set of the selected set type.
      • The position where the DBCS inserts the record into the set is determined by the set-ordering criteria defined in the schema for set-name.
  6. Unless otherwise specified by the RETAINING clause (see Section 4.9.1, RETAINING Clause), the DBCS updates the set type currency indicators for the reconnected sets to point to the connected record.
  7. If a database exception condition occurs during the execution of a RECONNECT statement, the DBCS places a database exception condition code in the special register DB-CONDITION (see Technical Notes). This code identifies the condition.

Technical Notes

RECONNECT statement execution can result in these DB-CONDITION database exception condition codes:

DBM$_CRUN_NULL The currency indicator for the run unit is null.
DBM$_CRUN_POS The currency indicator for the run unit points to a vacated position in the database.
DBM$_WRONGRTYP The record type of record-name is not identical to the current record type.
DBM$_CSTYP_NULL There is no current of set type for the set specified in the TO set-name phrase. This occurs only if the set is not a singular set.
DBM$_DUPNOTALL A sort key data item in the record to be reconnected is the same as the sort key of a record already in the set.
DBM$_FIXED The program attempted to reconnect a FIXED member record from one set type to another set of a given set type.
DBM$_NOT_UPDATE The realm is not in ready update usage mode.
DBM$_NOT_MBR You attempted to reconnect a record to a set in which it is not a member.
DBM$_CHKMEMBER The Oracle CODASYL DBMS CHECK (member) condition was evaluated to be false. The database has not been changed.

Additional References

  • Section 2.2, on reserved words (database special registers)
  • HP COBOL Reference Manual, Chapter 6, section on scope of statements
  • Section 4.8.1, on database On Error condition
  • Section 5.14.1, on RETAINING clause
  • USE statement

Example

This example shows how to change a record's set membership (terminal classifications) when the record (VT3) is a MANDATORY member. (OPTIONAL members must be DISCONNECTED from the old set occurrence and CONNECTED to the new set occurrence.)



MOVE "TERMINALS NOT SUP" TO CLASS_DESC.
FIND FIRST CLASS-REC WITHIN ALL_CLASS
      USING CLASS_DESC.

MOVE "VT3" TO PART_DESC.
FIND FIRST PART WITHIN ALL_PARTS_ACTIVE.
      USING PART_DESC
      RETAINING CLASS_PART.

    RECONNECT PART WITHIN CLASS_PART.


ROLLBACK

Function

The ROLLBACK statement ends your database transaction, nullifies all database changes made by this run unit since its last quiet point, and establishes a new quiet point for this run unit.


stment

is an imperative statement executed for an on error condition.

stment2

is an imperative statement executed for a not on error condition.

Syntax Rules

  1. The STREAM clause cannot be specified if the subschema entry (DB) does not name a stream.

General Rules

  1. The ROLLBACK statement ends your database transaction.
  2. All keeplists are emptied.
  3. If you do not use the STREAM clause, the ROLLBACK statement does the following:
    • Nullifies all database changes made by the run unit since the last quiet point
    • Terminates the ready mode of all ready realms for the run unit
    • Establishes a new quiet point for the run unit
  4. If you use the STREAM clause, the ROLLBACK statement does the following:
    • Nullifies all database changes made by this stream since the last quiet point
    • Terminates the ready mode of all ready realms for this stream
    • Establishes a new quiet point for this stream
  5. All currency indicators are set to null.
  6. All realm and record locks are released. These records and realms are now available to concurrent run units.
  7. To begin another transaction, the program must execute another READY statement after it executes the ROLLBACK statement.
  8. If the run unit abnormally terminates, the DBCS executes an implicit ROLLBACK statement.
  9. If a database exception condition occurs during the execution of a ROLLBACK statement, the DBCS places a database exception condition code in the special register DB-CONDITION. This code identifies the condition.

Additional References

  • Section 2.2, on reserved words (database special registers)
  • HP COBOL Reference Manual, Chapter 6, section on scope of statements
  • Section 4.8.1, on database On Error condition
  • USE statement (USE FOR DB-EXCEPTION)
  • Section 5.2.4, on subschema description (DB)

Example

This ROLLBACK example illustrates one way to end a database transaction and undo the changes made to the database during the transaction.


010-BEGIN-UPDATE-TRANSACTION.

* This transaction begins with the first READY statement in
* the run unit, continues through a series of DML database
* access statements, and ends with a COMMIT or ROLLBACK.
    .
    .
    .

100-END-UPDATE-TRANSACTION.

    DISPLAY "DO YOU WANT TO COMMIT THIS TRANSACTION ? ".
    ACCEPT ANSWER.
    IF ANSWER = "YES"
       COMMIT ...
     ELSE
       ROLLBACK
            ON ERROR
               IF DB-CONDITION = DBM-NOT-BOUND
                  DISPLAY " Database not bound"
               ELSE
                  CALL "DBM$SIGNAL".
               END-IF
            END-ROLLBACK.


Previous Next Contents Index