Formonly fields
FORMONLY
form fields define their data type
explicitly, with or without referencing a database columns.
Syntax
item-type item-tag = FORMONLY.field-name
[
TYPE
{
LIKE [
table.]
column
|
datatype [
NOT NULL]
}
]
[
, attribute-list ]
;
where datatype is one of:
{
CHAR
|
DECIMAL [
(p[
,s]
)]
|
SMALLFLOAT
|
REAL
|
FLOAT
|
MONEY [
(p[
,s]
)]
|
INTEGER
|
SMALLINT
|
DATE
|
VARCHAR
|
TEXT
|
BYTE
|
INTERVAL interval-qualifier
|
DATETIME datetime-qualifier
|
BIGINT
|
BOOLEAN
}
- table is the name or alias of a table, synonym, or view, as declared in the
TABLES
section. - column is the name of a database column.
- field-name is the identifier that will be used in programs to handle the field.
- interval-qualifier is an
INTERVAL
qualification clause such asHOUR(5) TO SECOND
. - datetime-qualifier is a
DATETIME
qualification clause such asDAY TO SECOND
.
Usage
Form fields can be specified with the FORMONLY
prefix, when there is no
corresponding database column, or when the field must be defined with another name to that of the
database column.
The data type of a form field is only used by the CONSTRUCT
interactive statement to do database queries. When using the form field with an
INPUT
, INPUT ARRAY
or DISPLAY ARRAY
dialog, the
type of the program variable defines the data type of the form field.
When using the LIKE
syntax, the form field gets the
data type of the specific table column as defined in the database schema. The table name must be specified in the [
table.]
columnTABLES
section.
When using the TYPE datatype
clause, you explicitly specify
the type of the field.
For CHAR
/VARCHAR
data types, the size is defined by the item
tag length in the layout.
If no data type is specified, and no database column is referenced, the default data type
is CHAR
.
Specifying a data type followed by the NOT NULL
keyword is equivalent to
the NOT NULL
attribute.
The STRING
data type is not supported in FORMONLY
form
field definitions.
The definition of FORMONLY
fields can be completed by using the DISPLAY LIKE
and
VALIDATE LIKE
attributes, to get the display and validation attributes from the .att
and .val database schema files.
Example
LAYOUT
GRID
{
[f001 ]
[f002 ]
...
}
END
END
ATTRIBUTES
EDIT f001 = FORMONLY.total TYPE DECIMAL(10,2), NOENTRY ;
EDIT f002 = FORMONLY.name TYPE LIKE customer.cust_name,
VALIDATE LIKE customer.cust_name ;