Usage / Programming with DIALOG |
The INPUT and INPUT ARRAY sub-dialogs provide the WITHOUT DEFAULTS option to use program variable values when the dialog starts, or to apply the DEFAULT attribute defined in forms. The semantics of this options is slightly different in INPUT and INPUT ARRAY dialogs. The WITHOUT DEFAULTS clause should always be used in INPUT ARRAY.
The WITHOUT DEFAULTS option can be used in the binding clause or as an ATTRIBUTE. When used in the binding clause, the option is defined statically at compile time as TRUE. When used as an ATTRIBUTE option, it can be specified with an integer expression that is evaluated when the DIALOG interactive instruction starts:
INPUT BY NAME p_cust.* ATTRIBUTE (WITHOUT DEFAULTS = NOT new) ... END INPUT
In the default mode, the INPUT sub-dialog clears the program variables and assigns the values defined by the DEFAULT attribute in the form file (or indirectly, the default value defined in the database schema files). This mode is typically used to input and INSERT a new record in the database. The REQUIRED field attributes are checked to make sure that the user has entered all data that is mandatory. Note that REQUIRED only forces the user to enter the field, and can leave the value NULL unless the NOT NULL attribute is used. Therefore, if you have an AFTER FIELD or ON CHANGE control block with validation rules, you can use the REQUIRED attribute to force the user to enter the field and trigger that block.
In contrast, the WITHOUT DEFAULTS option starts the dialog with the existing values of program variables. This mode is typically used in order to UPDATE an existing database row. Existing values are considered valid, thus the REQUIRED attributes are ignored when this option is used.
The NOT NULL field attribute is always checked at dialog validation, even if the WITHOUT DEFAULTS option is set.
With the INPUT ARRAY sub-dialog, the WITHOUT DEFAULT clause defines whether the program array is populated when the dialog begins. Once the dialog is started, existing rows are always handled as records to be updated in the database (i.e. WITHOUT DEFAULTS=TRUE), while newly created rows are handled as records to be inserted in the database (i.e. WITHOUT DEFAULTS=FALSE). In other words, column default values defined in the form specification file or the database schema files are only used for new created rows.
It is unusual to implement an INPUT ARRAY sub-dialog with no WITHOUT DEFAULTS option, because the data of the program variables would be cleared and the list empty. This default in INPUT ARRAY used inside DIALOG is WITHOUT DEFAULTS=TRUE, but in singular INPUT ARRAY, the default is WITHOUT DEFAULTS=FALSE.