Previous Topic

Next Topic

Declare Table

Valid in: ESQL

The Declare Table statement lists the columns and data types associated with a database table, for the purpose of program documentation. The declare table statement is a comment statement inside a variable declaration section and is not an executable statement. You cannot use host language variables in this statement.

The dclgen utility includes a declare table statement in the file it generates while creating a structure corresponding to a database table. The dclgen utility is described in detail in the Embedded SQL Companion Guide.

The embedded SQL preprocessor does not generate any code for the declare table statement. Therefore, in a language that does not allow empty control blocks (for example, COBOL, which does not allow empty IF blocks), the declare table statement must not be the only statement in the block.

Previous Topic

Next Topic

Syntax

The Declare Table statement has the following format:

EXEC SQL DECLARE [schema.]table_name TABLE
              (column_name data_type [WITH NULL | NOT NULL [WITH DEFAULT]]
              {, column_name data_type})

Previous Topic

Next Topic

Permissions

All users are permitted to use this statement.

Previous Topic

Next Topic

Example: Declare Table

The following is a Declare Table statement example for a database table:

exec sql declare employee table
       (eno           integer2 not null,
       ename   char(20) not null,
       age            integer1,
       job            integer2,
       sal            float4,
       dept           integer2 not null);


© 2007 Ingres Corporation. All rights reserved.