A Database Schema, or DB-Schema, is a representation of a database structure, which describes table names, fields, relationships between them, data types, indexes, views, synonyms, and stored procedures. A compilation with the DB-Schema can have an improved performance compared to the usual compilation. Also, a compilation with the DB-Schema does not require a connection to the database.
Lycia supports compilation with DB-Schema files generated by the qexpt tool (*.xml) and *.sch schema files.
To use a DB-Schema in your program compilation, you must set certain environment variables and create a Schema using the qexpt tool.
Step 1. Open the Terminal and export the environment variables for the connection to the database server:
export LOGNAME=<login> #the user name valid on Informix database server
export INFORMIXPASS=<password> #the password valid on Informix database server
export INFORMIXSERVER=<db_server> #the default database server to which an explicit or implicit connection is made by an SQL API client, the DB-Access utility, or another IBM® Informix product
export INFORMIXDIR=/opt/ibm/informix #the directory which contains sub-directories in which your Informix client is installed
export INFORMIXSQLHOSTS=/configs/lycia/sqlhosts.std #the location for the sqlhosts config file
export DB_LOCALE=en_US.utf8 #the Informix database locale, which the Informix database server uses to process locale-sensitive data
export CLIENT_LOCALE=en_US.utf8 #the language, territory, and code set that the client application uses in I/O operations, end user formats, and processing ESQL statements.
Step 2. In the Terminal, use the qexpt commands to generate the DB-Schema, like in the following example:
/opt/Querix/Lycia/bin/qexpt --format xml -d informix --database <db_name> --table-only
The qexpt generates a DB-Schema into the file in XML format. If the -o option is not used along with the qexpt command, the file is placed in the current directory.
Step 3. Make sure also to set values appropriate to the current compilation demands for the following environment variables:
The schema to be used in compilation is defined with the following statements:
The DB-Schema file must reside in one of the following places:
If you specify the folder along with the file name in the SCHEMA statement, the compiler will search for such folder in the current directory or in the folders listed by $FGLDBPATH.
Usage of the DB-Schema file can be overridden by the environment variable QX_USE_DB_SCHEMA_FILE: if it is set to false, the DATABASE statement will force a connection to the database instead of loading the DB-Schema file.
After the environment variables have been set, and the schema has been created or imported and placed into one of the mentioned locations, find your program, and compile it.