VMS Help  —  RDML72  Statements  RDB$DB_KEY, Examples  Pascal Example
    program db_key (input,output);
    DATABASE PERS = FILENAME 'PERSONNEL';

    type
        Rdb_Key_Type = BASED ON EMPLOYEES.RDB$DB_KEY;
        Rdb_Name_Type =  BASED ON EMPLOYEES.LAST_NAME;
    var
        Rdb_Key_Array  : ARRAY [1..101] OF Rdb_Key_Type;
        Rdb_Name_Array : ARRAY [1..101] OF Rdb_Name_Type;
        Cnt : INTEGER := 1;

    begin
    READY PERS;
    START_TRANSACTION READ_ONLY;

    FOR FIRST 100 E IN EMPLOYEES SORTED BY E.EMPLOYEE_ID
        Rdb_Key_Array[Cnt] := E.RDB$DB_KEY;
        Rdb_Name_Array[Cnt] := E.LAST_NAME;
        WRITELN(E.LAST_NAME, ' - 1st pass');
        Cnt := Cnt + 1;
    END_FOR;

    for Cnt := Cnt - 1 downto 1 do
        FOR E IN EMPLOYEES
        WITH E.RDB$DB_KEY = Rdb_Key_array[Cnt]
            if  E.LAST_NAME <> Rdb_Name_Array[Cnt]
            then
                writeln (E.LAST_NAME, 'DOES NOT MATCH',
                    Rdb_Name_Array[Cnt])
            else
                                 writeln (E.LAST_NAME, ' - 2nd pass');
        END_FOR;

    COMMIT;
    FINISH;
    end.
Close Help