READ-ONLY directive

The READ-ONLY directive allows you to make some fields (columns) of data read-only, while preserving normal access to other fields/columns. When placed immediately before a data item in an FD, this directive assigns the read-only attribute to the item. The read-only attribute applies only to elementary items and not to group items. Subsequent data items return to normal read-write access.

Note: Use the READ-ONLY directive if you want to tag fields (columns) of data as read-only. Use the READ_ONLY configuration variable if you want to designate all of the files belonging to a data source name (DSN) as read-only.

Syntax

$XFD READ-ONLY

In the code creating the animals table, the owner data item has been designated as read-only. The code is:

       FILE SECTION.
       FD  jr-file.
      $XFD COMMENT  This sample file demonstrates directives.
       01  jr-record.
           03  animal-info.
      $XFD NAME=PATIENT, NUMERIC 
               05  patient-id                  pic x(5).
               05  atype                       pic x.
               05  ctype redefines atype       pic x.
               05  dtype redefines atype       pic x.
               05  otype redefines atype       pic x.
           03  owner-info.
               05  phone                       pic x(8).
      $XFD READ-ONLY 
               05  owner                       pic x(30). 
           03  financial.
               05  acct_no.
                   10  year                    pic x(2).
                   10  seq_no                  pic x(4).
      $XFD DATE=YYYYMMDD, USE GROUP 
               05  last_visit.
                   10  yyyy                    pic 9(4).
                   10  mm                      pic 9(2).
                   10  dd                      pic 9(2).
      $XFD HIDDEN 
               05  fee                         pic s9(5)v99.
      $XFD DATE=MMDDYYYY
               05  date_paid                   pic 9(8).

In the database table, the owner column looks the same as the other columns. However, if users attempt to modify data in the owner column, they receive a message telling them that the update on a linked table failed.