VMS Help  —  RDML72  Statements  STORE Statement, Examples
    The following programs demonstrate the use of the STORE
    statement. The programs:

    o  Prompt the user for information to store in the COLLEGES
       relation

    o  Start a READ_WRITE transaction

    o  Use a STORE statement to store the user input into the
       COLLEGES relation

    o  Use the GET statement to store the value of the dbkey for
       the newly stored record into the host variable my_db_key.
       (Retrieving the dbkey is not a required part of the STORE
       statement syntax, but may be helpful in some applications.)

1  –  C Example

    DATABASE PERS = FILENAME "PERSONNEL";

    extern void read_string();
    static DEFINE_TYPE coll_code SAME AS COLLEGES.COLLEGE_CODE;
    static DEFINE_TYPE coll_name SAME AS COLLEGES.COLLEGE_NAME;
    static DEFINE_TYPE coll_city SAME AS COLLEGES.CITY;
    static DEFINE_TYPE coll_state SAME AS COLLEGES.STATE;
    static DEFINE_TYPE post_code SAME AS COLLEGES.POSTAL_CODE;
    static DEFINE_TYPE my_db_key SAME AS COLLEGES.RDB$DB_KEY;

    main()
    {
    read_string ("Enter College Code: ", coll_code, sizeof(coll_code));
    read_string ("Enter College Name: ", coll_name, sizeof(coll_name));
    read_string ("Enter College City: ", coll_city, sizeof(coll_city));
    read_string ("Enter College State: ",coll_state, sizeof(coll_state));
    read_string ("Enter Postal Code: ", post_code, sizeof(post_code));

    READY PERS;
    START_TRANSACTION READ_WRITE;

    STORE C IN COLLEGES USING
       strcpy (C.COLLEGE_CODE, coll_code);
       strcpy (C.COLLEGE_NAME, coll_name);
       strcpy (C.CITY, coll_city);
       strcpy (C.STATE, coll_state);
       strcpy (C.POSTAL_CODE, post_code);
       GET
          my_db_key = C.RDB$DB_KEY;
       END_GET;
    END_STORE;

    COMMIT;
    FINISH;
    }

2  –  Pascal Example

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

    var
       DECLARE_VARIABLE coll_code SAME AS COLLEGES.COLLEGE_CODE;
       DECLARE_VARIABLE coll_name SAME AS COLLEGES.COLLEGE_NAME;
       DECLARE_VARIABLE coll_city SAME AS COLLEGES.CITY;
       DECLARE_VARIABLE coll_state SAME AS COLLEGES.STATE;
       DECLARE_VARIABLE post_code SAME AS COLLEGES.POSTAL_CODE;
       DECLARE_VARIABLE my_db_key SAME AS COLLEGES.RDB$DB_KEY;
    begin
       writeln ('Enter College Code:');
       readln  (coll_code);
       writeln ('Enter College Name:');
       readln  (coll_name);
       writeln ('Enter College City:');
       readln  (coll_city);
       writeln ('Enter College State:');
       readln  (coll_state);
       writeln ('Enter College Postal Code:');
       readln  (post_code);

       READY PERS;
       START_TRANSACTION READ_WRITE;

       STORE C IN COLLEGES USING
          C.COLLEGE_CODE := coll_code;
          C.COLLEGE_NAME := coll_name;
          C.CITY := coll_city;
          C.STATE := coll_state;
          C.POSTAL_CODE := post_code;
          GET
            my_db_key = C.RDB$DB_KEY;
          END_GET;
       END_STORE;

       COMMIT;
       FINISH;
    end.
Close Help