DECLARE TABLE

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Describes the structure of a table to the preprocessor, gpre, before it is created with CREATE TABLE. Available in gpre.

DECLARE table TABLE (table_def);
Argument Description

<table>

Name of the table; table names must be unique within the database.

<table_def>

Definition of the table; for complete table definition syntax, see CREATE TABLE.

Description: DECLARE TABLE causes gpre to store a table description. You must use it if you both create and populate a table with data in the same program. If the declared table already exists in the database or if the declaration contains syntax errors, gpre returns an error.

When a table is referenced at run time, the column descriptions and data types are checked against the description stored in the database. If the table description is not in the database and the table is not declared, or if column descriptions and data types do not match, the application returns an error.

DECLARE TABLE can include an existing domain in a column definition, but must give the complete column description if the domain is not defined at compile time.

DECLARE TABLE cannot include integrity constraints and column attributes, even if they are present in a subsequent CREATE TABLE statement.

Important:
DECLARE TABLE cannot appear in a program that accesses multiple databases.

Example: The following embedded SQL statements declare and create a table:

EXEC SQL
DECLARE STOCK TABLE
(MODEL SMALLINT,
MODELNAME CHAR(10),
ITEMID INTEGER);
EXEC SQL
CREATE TABLE STOCK
(MODEL SMALLINT NOT NULL UNIQUE,
MODELNAME CHAR(10) NOT NULL,
ITEMID INTEGER NOT NULL,
CONSTRAINT MOD_UNIQUE UNIQUE (MODELNAME, ITEMID));

See Also

Advance To: