Phantom fields
A PHANTOM
field defines a screen-record field which is not rendered in
the layout (it acts as a hidden field).
Syntax
PHANTOM { [table.]column
| FORMONLY.field-name
[ TYPE
{ LIKE [table.]column
| data-type [NOT NULL] }
]
} ;
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:
A PHANTOM
field defines a form field listed in a screen-record or
screen-array, that has no corresponding layout element. It is only used for the
screen-record (or screen-array) definition, to bind with program variables used by
dialogs, typically to match a given database table definition.
Phantom fields are used by dialog instructions as regular form fields, but are not displayed to the end user, and the end user is not able to enter values for these fields. Data held by phantom fields is never send to the front-ends. They can be used to store critical data that must not go out of the application server.
Phantom fields can be based on columns defined in a database schema file, or as FORMONLY
field.
For example, if you want to implement a screen-array with all the columns of a
database table defined in the database schema file, but you don't want to display
all the columns in the TABLE
container of the
LAYOUT
section, you must use PHANTOM
fields. With
the screen-array matching the database table, you can easily write program code to
fetch all columns into an array defined with a LIKE
clause.
Example (grid-based layout)
Form file:
SCHEMA carstore
LAYOUT( TEXT = "Vehicles" )
GRID
{
<T t1 >
Num Name Price
[c1 |c2 |c3 ]
[c1 |c2 |c3 ]
[c1 |c2 |c3 ]
}
END
END
TABLES
vehicle
END
ATTRIBUTES
TABLE t1: table1;
EDIT c1 = vehicle.num;
EDIT c2 = vehicle.name;
EDIT c3 = vehicle.price;
PHANTOM vehicle.available; -- not used in layout
END
INSTRUCTIONS
SCREEN RECORD sr(vehicle.*);
END
Program code:
SCHEMA carstore
...
DEFINE vl DYNAMIC ARRAY OF RECORD LIKE vehicle.*
...
DISPLAY ARRAY vl TO sr.*
...