10.14.8 Insert a Record (INSERT)

Syntax

INSERT [INTO] fname ;

Fname is an internal file name declared earlier.

Purpose

INSERT adds a record to fname. Only those fields which are declared in the FIELDS declaration will contain values in the record. All other fields in the data file not declared will be set to zeros. INSERT does not check for duplicate records and will add duplicates if so directed. Any errors that occurred during the insertion may be found by calling the ERROR function. In addition, the function FILEFULL may be called after the INSERT statement is executed to determine if the file was already full when the insert was attempted.

Example:

/* assign new values to be added */

mag = "rd"

title = "Reader's Digest"

year_rate = 18.75;

subscribers = 0;

INSERT INTO mag;

IF ERROR (mag) THEN

PRINT "Unable to add magazine:",

mag, NL;

Notes

A report program that includes this statement causes the referenced file to be locked when the report begins. The file stays locked until the report completes.