HP OpenVMS Systems

ask the wizard
Content starts here

Updating records; sequential variable RMS file?

» close window

The Question is:

Using DCL, I want to maintain an ASCII file, which contains variable
records. I am writing to it using write/update statement. But sometimes, new
contents are of different size than the existing record. And this is not
allowed in DCL. Is there any way aro
und? It is very important for me to maitain this type of file.

The Answer is :

  The DCL command WRITE/UPDATE uses the RMS $UPDATE function and this
  does NOT allow for changing record size.  A look at the OpenVMS Guide
  to File Applications manual will show how changing a record size in
  a variable length record file would require RMS to re-pack the rest
  of the file:
  The solution then is to READ the input file, and WRITE a new output
  file.  The application would have to read the input file already, as
  DCL does not offer random access to variable length files. The price
  would be that all data must be written where perhaps only a few records
  are updates and a new file must be allocated.  The additional writes may
  be minimal, as RMS BUFFERS records and to update an 80 byte record, it
  will write out at least 512 bytes, but more often 8KB ($SHOW RMS).  Thus
  a single write IO may update multiple records.
  If the new record is shorter, then with some application cooperation
  you may be able to 'fake it' by for example filling the remainder of
  the record with NULL characters, spaces, or an extra (LF) terminator.
  This problem is quite analogous to that of writing new record data into
  the middle of a file on a sequential medium such as magnetic tape...
  Alternatively -- though you have apparently discounted it -- consider
  using a sequential file format with fixed records or a relative file.

answer written or last revised on ( 17-JAN-2000 )

» close window