Creating SQL tables

These features are only supported for SQL-CREATE-TABLE.

Nullability

By default, SQL-CREATE-TABLE sets all columns to nullable, unless the processing code in the output conversion or correlative is mi (for must input). Nullable means that a null value can be entered in the column. Unlike D3, null values are displayed in SQL as NULL and not as an empty string or a blank.

In addition to specifying the data type, a constraint called NOTNULL (with no space between NOT and NULL) can be specified on the command line of SQL-CREATE-TABLE. Using the NOTNULL constraint in the SQL-CREATE-TABLE command is equivalent to specifying NOT NULL in the SQL statement, CREATE TABLE. This constraint indicates that null values are not permissible in any row of the table for the specified column.

To specify the NOTNULL constraint, a command line attribute argument should take the form, attribute=data_type|NOTNULL. No spaces are permitted around the = character or the | character.

In the example below, the constraint ensures that each row in the CUST table will have a non-null value for AGE.

SQL-CREATE-TABLE CUST AGE=integer|NOTNULL

Correlatives

Columns that are based on attribute-defining items with translate correlatives should not be updated through SQL. Translate correlatives can be considered "one-way," that is output only. Data inserted into the D3 file through SQL is the translated data and not the raw (untranslated) data. Thus, updating or inserting data into these columns will cause unexpected results.

A correlative can include a call to a FlashBASIC subroutine. However, ACCESS functions in the subroutine are not functional at the column-level, that is, when the subroutine is defined as part of the correlative of an attribute-defining item.

Triggers

D3 SQL supports triggers and referential integrity via a special database file option called a callx correlative. To implement a callx trigger, you must first be familiar with FlashBASIC, as this is the language supported by such triggers. For more information on FlashBASIC, see the D3 Reference Manual.