UPDATE, UPDATAB (FILELIST)


 

The UPDATE instruction modifies a record in place. Any changes to the keys of secondary files are automatically updated.

 

 

[label]

UPDATE

{filelist};{list}

 

Where:

label

Optional. A Program Execution Label.

filelist

Required. A previously defined and opened FILELIST variable defining the primary and secondary files in which data is updated.

list

Required. Any combination of previously defined Character String Variables, Numeric Variables, String Expression, string or numeric ARRAYS, individual array elements, VARLISTs of string or numeric variables, or valid Disk I/O List Controls.

Flags Affected: OVER

Note the following:

  1. The instruction requires that the last read operation on any one of the FILELIST files must have been a valid read operation.

  2. The instruction will update all keys of the ISAM or AAM files defined in the FILELIST that are changed by the {list} variables.

    WARNING: When the update changes the key for an ISAM file in the FILELIST, the current key pointer for this ISAM file is changed to the new key position in the ISI tree. Therefore, any READKS or READKP instruction for an IFILE in the FILELIST whose key has been changed reads the key sequential record relative to the new key pointer position. 

  3. The instruction operation will synchronize the primary file to the last valid FILELIST file read and update the text data record.

  4. Should an error occur for any part of the operation, the runtime attempts to restore the old record and associated keys to their original state prior to the operation.

  5. All other aspects of the UPDATE instruction are defined in the UPDATE AFILE or UPDATE IFILE topics.

  6. When the FILELIST files have been opened for record locking and the SINGLE record locking mode is used, the UPDATE FILELIST instruction searches all of the files in the FILELIST to release the record lock from the file that performed the last READ operation. The record lock is only released for the record that was just updated.

Example:

 

MyList

FILELIST

 

Prime

IFILE

NAME="Prime.isi"

Second

IFILE

NAME="Second.isi"

  

FILELISTEND

 

KEY2

INIT

"TEST2"

.

 

 

  

OPEN

MyList

  

WRITE

MyList;"TEST1 Record data"

  

WRITE

MyList;"TEST2 Record data"

.

 

 

  

FILEPI

2;MyList

  

READ

Second,KEY2;S$CMDLIN

  

IF OVER

 

  

  

; User Over Logic.....

  

ELSE

 

  

UPDATE

MyList;"TEST3 Record news"

  

IF OVER

 

  

  

; User Update Over Logic.....

  

ENDIF

 

  

ENDIF

 

  

CLOSE

MyList

 

This example opens a FILELIST containing two index files. Two records are written to the FILELIST. Data is written to the primary file (prime) and the key is constructed and inserted into its ISAM file. The key for the secondary file (second) is also constructed and inserted into its ISAM file. The subsequent READ instruction positions the FILELIST to the second record. The UPDATE instruction rewrites the data using the TEST3 string. Both the primary and secondary ISAM keys are updated as required. Both files are then closed.

 

 

See Also:READ (FILE), WRITE (FILELIST), Disk I/O Instructions

 



PL/B Language Reference UPDATE, UPDATAB (FILE) UPDATE, UPDATAB (IFILE)