Database schemas hold the definition of the database tables and
columns.
In program sources or form specification files, you must specify the database schema file
with the SCHEMA instruction. When the database schema is specified, you
can define program variables by referencing the database table or column name. The
program variables will get the type of the database column as defined in the schema
file.
Note: To improve compilation time, the fglcomp compiler will
automatically generate a .42d index file from the
.sch schema file, in the same directory as the
.sch file. When the .sch file changes, the
.42d index file is re-generated, and can be safely removed, if you
want to cleanup your projet.
The FGLDBPATH environment variable can be used to define a list of directories where the
compiler can find database schema files.
The schema files contain the column data types (.sch file), validation rules (.val file), and
tty display attributes (.att) for columns.
Note: The .val and .att files are supported
for backward compatibility and should not be used in new developments.
The data types, display attributes, and validation rules are taken
from the database schema files during compilation.
Make sure that the schema files of the development database
correspond to the production database, otherwise the elements defined
in the compiled version of your modules and forms will not match
the table structures of the production database.
Program variables can be defined with the
LIKE keyword
to get the data type defined in the schema files:
SCHEMA stores
MAIN
DEFINE custrec RECORD LIKE customer.*
DEFINE name LIKE customer.cust_name
...
END MAIN
The database schema files are generated with the fgldbsch tool from the system tables of
an existing database.
Note: It is strongly recommended that you regenerate the schema files when upgrading to
a new compiler version. Bug fixes and new data type support can required schema file
changes. If the schema file holds data type codes that are unknown to the current
version, the compilers will raise the error
-6634.
The fgldbsch must connect to the database server, with a db user allowed to query the
database system tables (for example, INFORMATION_SCHEMA in a MySQL database).
Note: For some type of databases, the table owner is mandatory to extract schema
information. If you do not specify the -ow option in the comment line, fgldbsch will
take the -un user name as default. If you do not use the -un/-up options because you
are using indirect database connection with FGLPROFILE settings to identify the
database user, or if the database user is authenticated by the operating system, the
fgldbsch tool will try to identify the current database user after connection and
use this name as table owner to extract the schema.