Defining Insertable Tables

Marking a table as insertable allows SQL INSERT and DELETE statements to be attempted, which, if successful, will update the underlying COBOL data file. Its success depends on a set of rules that each insertable table must follow.

Within the table form, you define a table as insertable by selecting the Allow Inserts tick-box. which allows an ODBC application to attempt an INSERT on the table.

In order for the INSERT to be successful, the table must, in general, have a format that will allow a single COBOL data record to be populated and written into the COBOL data file. To create the underlying COBOL data record based on the information provided in the INSERT statement, there are a number of rules that must be adhered to; Refer to Rules for Insertable Tables for a full list of rules.

Note:
  • An SQL INSERT statement does not have to specify column values for all columns of the table. For columns not specified, NULL is implied; therefore, those columns not specified must be marked as nullable in the Properties pane:

  • The Relativity DBMS must create a COBOL data record that would generate the new row implied by that SQL INSERT statement. Since the relational table derived from the COBOL record may not have columns based on all the data items in the record, the Relativity DBMS must be able to synthesize values for all those data items not represented in a relational row of the table.

    This synthesis is accomplished through various, sometimes subtle, means. The most obvious method is default values for columns or data items - see Defining Custom Data Types. More subtle methods are those based on making table filters and record type filters true by setting appropriate values from condition-names into their conditional variables in the data record - see Defining Record Types and Defining Table Filters.

Essentially, the rules for insertable tables must guarantee that the Relativity DBMS can derive a value for every data item in the inserted data record in the event of partial information provided in the column values specified by the INSERT statement.

Relativity also allows SQL DELETE statements, but only if the table is marked as an insertable table.