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.