While MATCH and NEXT operations in MODIFY can operate on primary key or non-key columns and return single or multi-row answer sets, the MODIFY commands INCLUDE, UPDATE, and DELETE must always identify the target rows by their primary key. Therefore, in MODIFY, each update operation affects at most one row.
In Maintain, the FOR phrase in the update command determines the number of rows affected.
Suppose you want to display all the employees in a department and increase certain salaries:
MODIFY FILE EMPINFO CRTFORM LINE 1 " PLEASE ENTER A VALID DEPARTMENT </1" 1. " DEPARTMENT: <DEPARTMENT " 2. MATCH DEPARTMENT ON NOMATCH REJECT ON MATCH CRTFORM LINE 10 3. "EMP_ID: <D.EMP_ID SALARY: <T.CURRENT_SALARY> " 4. ON MATCH UPDATE CURRENT_SALARY ON MATCH GOTO GETREST CASE GETREST 5. NEXT EMP_ID ON NEXT CRTFORM LINE 10 " EMP_ID: <D.EMP_ID SALARY: <T.CURRENT_SALARY> " ON NEXT UPDATE CURRENT_SALARY ON NEXT GOTO GETREST 6. ON NONEXT GOTO EXIT ENDCASE DATA END
The MODIFY procedure processes as follows:
The lines displayed by this MODIFY procedure follow:
PLEASE ENTER A VALID DEPARTMENT DEPARTMENT: PRODUCTION EMP_ID: 071382660 SALARY: 11000.00
You can change the salary, or leave it as is. Each time you press Enter, the current salary is updated and the next employee ID displays:
EMP_ID: 119265415 SALARY: 9500.00 EMP_ID: 119329144 SALARY: 29700.00 EMP_ID: 123764317 SALARY: 26862.00 EMP_ID: 126724188 SALARY: 21120.00 EMP_ID: 451123478 SALARY: 16100.00
In Maintain, you can use stack columns as turnaround values to update a table. The following annotated Maintain request named UPDATE1 updates the same rows as the preceding MODIFY request:
MAINTAIN FILE EMPINFO 1. WINFORM SHOW WIN1 2. CASE MATCHREC FOR ALL NEXT EMP_ID INTO EMPSTACK WHERE DEPARTMENT EQ VALSTACK.DEPARTMENT ENDCASE 3. CASE UPDSAL FOR ALL UPDATE CURRENT_SALARY FROM EMPSTACK ENDCASE END
The Maintain processes as follows:
Executing the UPDATE1 procedure displays a Winform similar to the following:
Information Builders |