RDOHELP72.HLB  —  COMMIT
    Ends a transaction by writing to the database any changes made
    during that transaction. COMMIT also releases all locks and
    closes open streams.

    The COMMIT statement affects all open databases, all changes
    to data made with Oracle Rdb data manipulation statements, and all
    changes to data definitions made with Oracle Rdb data definition
    statements.

    Example:

    RDO>   START_TRANSACTION READ_WRITE
    RDO>   FOR J IN JOBS WITH J.JOB_CODE = "PLMR"
    cont>    ERASE J
    cont>  END_FOR
    RDO>   COMMIT

1  –  More

    If you have invoked a database, you have the necessary privileges
    to use the COMMIT statement.

    Because the COMMIT statement closes open streams, you should not
    use an explicit END_STREAM statement after a COMMIT statement. If
    you do, Oracle Rdb returns an error message.

2  –  Format

  (B)0COMMIT  qwqqqqqqqqqqqqqqqq>qqqqqqqqqqqqqqqqwwqqqqqqq>qqqqqqwq>
           mq> (TRANSACTION_HANDLE qq> var) qjmq> on-error qqj

2.1  –  TRANSACTION_HANDLE

    A keyword followed by a host language variable. A transaction
    handle identifies each instance of a transaction. If you do not
    declare the transaction handle explicitly, Oracle Rdb attaches an
    internal identifier to the transaction.

    In Callable RDO, use !VAL as a marker for host language
    variables.

    You can put parentheses around the host language variable name.

    Normally, you do not need to use this argument. The ability to
    declare a transaction handle is provided for compatibility with
    other database products and future releases of Oracle Rdb.

2.2  –  on-error

    Specifies host language statements or Oracle Rdb data manipulation
    statements to be performed if an Oracle Rdb error occurs. For more
    details, request HELP on ON_ERROR.

3  –  Examples

    The examples show:

    o  How to use COMMIT when modifying data in the database

    o  How to use COMMIT when creating data definitions

3.1  –  Modifying

    This example makes a change to a relation and writes that change
    to the database:

           DISPLAY "Enter employee's ID number:  "   <-- 1
             WITH NO ADVANCING.
           ACCEPT ID.
           DISPLAY "Percentage increase:  "    <-------- 2
             WITH NO ADVANCING.
           ACCEPT PERC.
           CALL "SYS$GETTIM" USING TODAY
                             GIVING RETURN_VALUE.

    &RDB&  START_TRANSACTION READ_WRITE      <---------- 3
    &RDB&     RESERVING SALARY_HISTORY FOR
    &RDB&     PROTECTED WRITE

    &RDB&  FOR S IN SALARY_HISTORY
    &RDB&    WITH  S.EMPLOYEE_ID = ID  AND   <---------- 4
    &RDB&      S.SALARY_END MISSING
    &RDB&    MODIFY S USING                  <---------- 5
    &RDB&        ON ERROR
                    GO TO ERROR-PAR
    &RDB&        END_ERROR
    &RDB&    S.SALARY_END = TODAY
    &RDB&    END_MODIFY

    &RDB&    STORE NEW IN SALARY_HISTORY USING    <----- 6
    &RDB&        ON ERROR
                   GO TO ERROR-PAR
    &RDB&        END_ERROR
    &RDB&      NEW.EMPLOYEE_ID = S.EMPLOYEE_ID;
    &RDB&      NEW.SALARY_AMOUNT =
    &RDB&        ( S.SALARY_AMOUNT *
    &RDB&        ( 1 + ( PERC / 100 ) ) );
    &RDB&      NEW.SALARY_START = TODAY
    &RDB&    END_STORE

    &RDB&  END_FOR

    &RDB&  COMMIT              <------------------------ 7

    This program fragment gives a raise to an employee. To maintain a
    consistent database, it performs the following operations:

    1. Prompts for an employee identification number (ID).

    2. Prompts for a percentage increase, which is used to calculate
       INCREASE.

    3. Starts a read/write transaction. This statement uses the
       RESERVING clause to protect the SALARY_HISTORY record against
       conflicting updates, while allowing users access to all the
       other relations in the database.

    4. Establishes a record stream consisting of the current SALARY_
       HISTORY record for the specified employee.

    5. Uses MODIFY to change the current salary record, by changing
       its date from missing to the current date (TODAY).

    6. Uses STORE to create a new SALARY_HISTORY record. Although
       this statement executes within the record stream defined
       by the FOR loop, it must declare a new context variable to
       identify the new record. All the fields of the new record
       can be derived from fields of the old one, except the start
       date, which must be calculated from the current date. Oracle Rdb
       calculates NEW.SALARY_AMOUNT from the S.SALARY_AMOUNT, using
       the specified percentage increase (PERC).

    7. Uses COMMIT to make the changes permanent to the database.

    Note that each data manipulation statement provides an ON ERROR
    clause. If an error occurs at any point in the transaction,
    control transfers to another paragraph, which contains a ROLLBACK
    statement. Therefore, this set of operations is never partially
    completed.

3.2  –  Defining

    This example shows how to use COMMIT to make a data definition
    permanent:

    RDO> DEFINE DATABASE 'INVENTORY'.
    RDO> SHOW DATABASES
    Database with db_handle INVENTORY in file INVENTORY
    RDO> DEFINE FIELD PART DATATYPE TEXT SIZE 10.
    RDO> DEFINE RELATION TEST.
    cont> PART.
    cont> END TEST RELATION.
    RDO>
    RDO> COMMIT
    RDO> SHOW RELATIONS
    User Relations in Database with db_handle INVENTORY
            TEST
    RDO> SHOW FIELDS
    User Fields in Database with db_handle INVENTORY
         PART                             text size is  10
    RDO> EXIT

    This example shows how to define a database, a field, and a
    relation. These statements would normally be in an indirect
    command file. After you define the database and its components,
    the COMMIT statement makes the database permanent. If you do not
    issue the COMMIT statement, RDO returns this message:

    There are uncommitted changes to a database or the data
    dictionary Would you like a chance to COMMIT these changes [NO]?
Close Help