Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

Format

More

Examples

on-error

context-var

record-descr

field-name

value-expr

RDB/VMS Relational Database Operator MODIFY — VMS RDB_4.0B

 Changes the value in a field in one or more records from a relation
 or open stream.  Before you use the MODIFY statement, you must start
 a read/write transaction and establish a record stream with a FOR
 statement or a START_STREAM statement.  The context variables you
 refer to in MODIFY statement must be the same as those defined in the
 FOR or START_STREAM statement.

 Example:

      RDO>  FOR E IN EMPLOYEES WITH E.EMPLOYEE_ID = "00175"
      cont>  MODIFY E USING
      cont>     E.LAST_NAME = "Smathers"
      cont>  END_MODIFY
      cont> END_FOR

Additional information available:

FormatMoreExamples

Format

 MODIFY ───> context-var ───┐
       ┌──────────<─────────┘
       └──> 
U

S

I

N

G
────┬──>────────────┬─────┐ └──> on-error ──┘ │ ┌──────────────────<─────────────────┘ ├──┬─> context-var . field-name ──> typebox (=) ───> value-expr ──┬─┐ │ └──────────────────── typebox (;) <──────────────────────────┘ │ │ │ └────> context-var . * ─────────> typebox (=) ───> record-descr ────┤ │ ┌───────────────────<───────────────────<─────────────────┘ └────> 
E

N

D

M

O

D

I

F

Y

Additional information available:

on-errorcontext-varrecord-descrfield-namevalue-expr

on-error

 The ON ERROR clause, which specifies a host language statement to be
 performed if an Rdb/VMS error occurs.

context-var

 A context variable declared in the FOR or START_STREAM statement.
 The MODIFY statement must appear after FOR or START_STREAM and before
 END_FOR or END_STREAM.

 You can modify fields in only one relation at a time.  That is, all
 the context variables on the left side of the assignment in a MODIFY
 statement must refer to the same relation.

record-descr

 A valid data dictionary record descriptor matching all the fields of
 the relation.

field-name

 The name of the field to be modified.

value-expr

 An Rdb/VMS value expression that specifies the new value for the
 modified field.

More

 You need the Rdb/VMS READ and MODIFY privileges to the relation and
 also the Rdb/VMS MODIFY privilege to the database to use the MODIFY
 statement.

Examples

 Example 1

 Modify a field value in a record:

    DISPLAY "Enter employee's ID number: " WITH NO ADVANCING.
    ACCEPT ID.
    DISPLAY "Enter new status code: " WITH NO ADVANCING.
    ACCEPT STATUS_CODE.

 &RDB&  START_TRANSACTION READ_WRITE

 &RDB&  FOR E IN EMPLOYEES WITH E.EMPLOYEE_ID = ID
 &RDB&    MODIFY E USING
 &RDB&        ON ERROR
                GO TO ERROR-PAR
 &RDB&        END_ERROR
 &RDB&      E.STATUS_CODE = STATUS_CODE
 &RDB&    END_MODIFY
 &RDB&  END_FOR

 &RDB&  COMMIT

 This COBOL example prompts for an identification number and a new
 status code and modifies the corresponding employee record.


 Example 2

 Update more than one relation at once:

        INPUT "What is employee's ID number"; ID_NUMBER

 &RDB&  START_TRANSACTION READ_WRITE RESERVING
 &RDB&                   JOB_HISTORY,
 &RDB&                   SALARY_HISTORY FOR
 &RDB&                   PROTECTED WRITE

 &RDB&  FOR JH IN JOB_HISTORY CROSS
 &RDB&           SH IN SALARY_HISTORY OVER EMPLOYEE_ID
 &RDB&               WITH JH.EMPLOYEE_ID = ID_NUMBER
 &RDB&               AND JH.JOB_END MISSING
 &RDB&               AND SH.SALARY_END MISSING

 &RDB&          MODIFY JH USING
 &RDB&                ON ERROR
                    GOTO 3000
 &RDB&                END_ERROR
 &RDB&             JH.JOB_END = TODAY
 &RDB&          END_MODIFY
 &RDB&          MODIFY SH USING
 &RDB&                ON ERROR
                    GOTO 3000
 &RDB&                END_ERROR
 &RDB&             SH.SALARY_END = TODAY
 &RDB&          END_MODIFY
 &RDB&       END_FOR
 &RDB&  COMMIT

 This BASIC example updates an employee record when the employee
 leaves the company.  This operation entails setting the missing
 JOB_END and SALARY_END fields to today's date.  In the example:

  o  The RSE in the FOR loop joins the JOB_HISTORY and SALARY_HISTORY
     relations and specifies the conditions on the records.  This
     record stream includes only the records where the end dates are
     missing (the current records) and where the EMPLOYEE_ID field
     values match.

  o  The two MODIFY statements are included within a single FOR loop.


                                 NOTE

         You can modify fields using a CROSS clause as long as
         the fields you are modifying are not involved in the
         join.

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026