SCHEMA

Identifies the database schema files to be used for compilation.

Syntax 1

SCHEMA dbname

Syntax 2

[DESCRIBE] DATABASE dbname
  1. dbname identifies the name of the database schema file to be used.

Usage

The SCHEMA dbname instruction defines the database schema files to be used for compilation, where dbname identifies the name of the database schema file to be used.

[DESCRIBE] DATABASE is supported for backward compatibility, use the SCHEMA instruction instead. The [DESCRIBE] DATABASE defines the compilation database schema and the default connection when the program starts, while SCHEMA defines only the compilation database schema.

The dbname database name must be expressed explicitly; it cannot be a variable as in a regular DATABASE instruction inside a program block.

Use the SCHEMA instruction outside any program block, before a variable declaration with DEFINE LIKE instructions. SCHEMA must precede any program block in each module that includes a DEFINE...LIKE declaration or INITIALIZE...LIKE and VALIDATE...LIKE statements. It must also precede any DEFINE...LIKE declaration of module variables.

Database schema information such as data types for DEFINE...LIKE are taken from the schema files during compilation. Make sure that the database schema file of the development database corresponds to the production database; otherwise the program variables defined in the p-code modules will not match the table structures of the production database.

The dbname can be written with different syntaxes:
  database
| database @ server
| "string"   -- for ex: "//server/database"

Such database specification is IBM® Informix® specific and should be avoided. Use simple database identifiers only, in lowercase.

When using a simple identifier for the database name, the compiler converts the name to lowercase before searching the schema file. However, if a double quoted string is used as database name, the name will be used as is to find the schema file.

With the SCHEMA instruction, the name of the database schema during development can be different from the name of the database source used at runtime.

SCHEMA dev_db -- Compilation database schema
DEFINE rec RECORD LIKE customer.*
MAIN
   DATABASE prod_db -- Runtime database specification
   SELECT * INTO rec.* FROM customer WHERE custno=1
END MAIN