The following programs demonstrate the use of the multiplication (*) arithmetic operator and the MODIFY statement. These programs select the record of an employee in the SALARY_HISTORY relation with a specified employee ID and that has no value for SALARY_ END. The purpose of specifying no value for SALARY_END is to ensure that the only salary amount affected is the employee's present salary. Next, the programs multiply the employee's salary by 1.1 to produce an increase of ten percent in his or her salary. The MODIFY statement replaces the old value in this employee's SALARY_AMOUNT field with the new value.
1 – C Example
#include <stdio.h> DATABASE PERS = FILENAME "PERSONNEL"; main() { READY PERS; START_TRANSACTION READ_WRITE; FOR SH IN SALARY_HISTORY WITH SH.EMPLOYEE_ID = "00164" AND SH.SALARY_END MISSING MODIFY SH USING SH.SALARY_AMOUNT = SH.SALARY_AMOUNT * 1.1; END_MODIFY; END_FOR; ROLLBACK; FINISH; }
2 – Pascal Example
program multiply (input,output); DATABASE PERS = FILENAME 'PERSONNEL'; begin READY PERS; START_TRANSACTION READ_WRITE; FOR SH IN SALARY_HISTORY WITH SH.EMPLOYEE_ID = '00164' AND SH.SALARY_END MISSING MODIFY SH USING SH.SALARY_AMOUNT := SH.SALARY_AMOUNT * 1.1; END_MODIFY; END_FOR; ROLLBACK; FINISH; end.