Previous Topic: Control UDB Performance and Resource Usage

Next Topic: SYSOUT Considerations

Add Records to a UDB

The &FILE ADD statement is used to add new records to a UDB. The &FILE PUT statement can also be used to add records. However, whereas &FILE ADD receives an error indication if a record with a like key exists, &FILE PUT will replace a record with a like key. If an NCL procedure is known to be creating new records then &FILE ADD should be used.

Before a record can be added, the key of the record must be identified. This is done using the KEY= or the KEYVAR= operand on the &FILE statement. The KEY= operand can be used in conjunction with the ADD and PUT operands.

The &FILE ADD statement is used to supply the data of the record to be added to the UDB. Depending on the format of the UDB this could be a text string, tokens, or an MDO.

The success of the &FILE ADD statement can be tested using the &FILERC (file return code) system variable. If the &FILE ADD statement was not successful, the &VSAMFDBK system variable will contain a standard VSAM completion code indicating the type of error that occurred. For example:

&FILE OPEN ID=MYFILE FORMAT=DELIMITED
&FILE ADD ID=MYFILE KEY='RECORD1' VARS=A* RANGE=(1,7)
&IF &FILERC NE 0 &THEN &WRITE ERROR CODE=&VSAMFDBK