VMS Help  —  RDML72  Statements  MODIFY
    Changes the value in a field or fields in one or more records
    from a relation in an open stream.

    Before you use a MODIFY statement, you must:

    o  Start a READ_WRITE transaction

    o  Establish a record stream with a FOR statement or START_STREAM
       statement

    The context variables referenced in a MODIFY statement must be
    the same as those defined in the FOR or START_STREAM statement.

1  –  Examples

    The following programs demonstrate the use of the MODIFY
    statement with a host variable. These programs:

    o  Declare a host variable, badge, with the same data type and
       attributes as EMPLOYEES.EMPLOYEE_ID

    o  Prompt for a value for badge

    o  Change the status code for the employee with the specified
       badge

    The C program uses the read_string function to prompt for and
    receive a value for badge. For more information on read_string,
    see Appendix B of the "RDML Reference Manual".

1.1  –  C Example

    #include <stdio.h>
    DATABASE PERS = FILENAME "PERSONNEL";

    extern void read_string();
    static DECLARE_VARIABLE badge SAME AS EMPLOYEES.EMPLOYEE_ID;

    main()
    {
    read_string ("Employee ID: ", badge, sizeof(badge));

    READY PERS;
    START_TRANSACTION READ_WRITE;

    FOR E IN EMPLOYEES WITH E.EMPLOYEE_ID = badge
       MODIFY E USING
          strcpy(E.STATUS_CODE,"1");
       END_MODIFY;
    END_FOR;

    ROLLBACK;
    FINISH;
    }

1.2  –  Pascal Example

    program modify_with_host (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';

    var
       DECLARE_VARIABLE badge SAME AS EMPLOYEES.EMPLOYEE_ID;

    begin
    write  ('Employee ID: ');
    readln (badge);

    READY PERS;
    START_TRANSACTION READ_WRITE;

    FOR E IN EMPLOYEES WITH E.EMPLOYEE_ID = badge
        MODIFY E USING
            E.STATUS_CODE := '1';
        END_MODIFY;
    END_FOR;

    ROLLBACK;
    FINISH;
    end.

2  –  Format

  (B)0MODIFY qqq> context-var qqqqq>  USING  qqqqwqqqqqqqqqqqqqqwqqqqk
                                             mqq> on-error qj    x
                                                                 x
  lqqqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
  x
  mqwqwqq>  statement  qqqqqqqqqqqqqqqqqqqqqqqqqqqwqwq> END_MODIFY
    x x                                           x x
    x mqq> context-var.* qq> = qq> record-descr qqj x
    x                                               x
    mqqqqqqqqqqqqqqqqqqqqqqqqqq<qqqqqqqqqqqqqqqqqqqqj

2.1  –  Format arguments

    context-var            A context variable. A temporary name that
                           you associate with a relation. You define
                           a context variable in a relation clause.
                           For more information see the entry on
                           Context Variables.

    on-error               The ON ERROR clause. Specifies host
                           language statement(s) to be performed
                           if an error occurs during the MODIFY
                           operation. For more information see the
                           entry on ON ERROR.

    statement              Any valid RDML or host language statement
                           to be executed within the MODIFY
                           operation. Use a semicolon (;) at the
                           end of each RDML, Pascal, or C statement.

    record-descr           A valid host language record descriptor
                           that matches all the fields of the
                           relation. Each field of the record
                           descriptor must match exactly the field
                           names and data types of the fields in the
                           Oracle Rdb relation referenced by the
                           context variable.
Close Help