7.78.2 INSERT Comments / Warnings
- Where fields are not specified for the new record they will adopt their default values as defined in the data dictionary. For example, if a record in file NAMES contained fields #CUSTNO (customer number), #NAME (customer name), #ADD1 (address line 1) and #POSTCD (post code), then the following command:
INSERT FIELDS(#CUSTNO #NAME) TO_FILE(NAMES)
would cause #ADD1 to be set to blanks in the new record and #POSTCD to be set to 2000 (if these were the data dictionary defaults for the fields).
- Note that when BLOB or CLOB data is inserted, it should be either *SQLNULL, *NULL or a filename. If a filename, it is assumed that the file exists and that the contents are to be copied into the BLOB or CLOB in the database.
- Any INSERT operation must include at least the "primary key fields" of the file. The primary key fields are specified when the file is set up. If the primary key fields are not specified the INSERT operation will fail with an "insufficient information" error.
For example, if the primary key of file NAMES is #CUSTNO then the following operations will fail:
INSERT FIELDS(#NAME #ADD1) TO_FILE(NAMES)
INSERT FIELDS(#POSTCD) TO_FILE(NAMES)
- When an SQL Null field is inserted into a table's database column, one of the following will occur:
- If the column has a default or automatically generated value defined (in the DBMS, not LANSA), the default value will be inserted, rather than the SQL Null.
- If the column does not have the NOT NULL constraint, the column is set to SQL Null.
- If the column does have the NOT NULL constraint, the insert will fail. (This can only occur if the database definition of the column does not match the LANSA definition of the field.)