HP OpenVMS Systems

ask the wizard
Content starts here

DCL access to RMS files?

» close window

The Question is:

I'm trying to manipulate an indexed file with DCL. I'm able to read records
 with READ/KEY= but I am unable to find a solution to update the record. I've
 tried to delete the record with READ/DELETE but somewhow things don't work.
 I've opened the file with
read/write so that can't be the problem. I have searched for examples of the
 read/delete but haven't found any.
Could you give me an example of how to update a indexed file using DCL and/or
 by using READ/DELETE.
Arno Reintjens

The Answer is :

  The relevent DCL command is:
    $ WRITE/UPDATE file record
  This command must follow RMS rules. Specifically:
    - The update is to a 'CURRENT' record which is established by
      a READ command (with optional /KEY or /INDEX).
    - The primary key values may never change. If the primary key
      needs to be changed, then READ/DELETE old record and WRITE
      the new record.
    - The record size can only change for Indexed files with variable
      length records configured.
$ convert/fdl=sys$input sys$input tmp.idx 	! Look ma, one liner :-)
file; org ind; key 0; seg0_l 5
< Exit >                                        ! Control-Z
aap  aap
noot noot
mies mies
< Exit >
$ type tmp.idx					! Notice re-ordering by key
aap  aap
mies mies
noot noot
$ open/read/write tmp tmp.idx
$ write tmp "teun teun"
$ read/dele/key="noot" tmp record
$ show symb record
  RECORD = "noot noot"
$ read/key="mies" tmp record
$ write/update tmp f$ext(0,5,record) + "vuurwerk" ! Keep key exactly the same
$ close tmp
$ type tmp.idx                        ! Noot deleted, Teun added, Mies updated.
aap  aap
mies vuurwerk
teun teun

answer written or last revised on ( 9-JUN-2000 )

» close window