Previous Topic: Schema Files SyntaxNext Topic: TABLE_INFO Statement


TABLE Statement

Defines the logical tables in the CA SDM database schema and the logical columns (fields) in those tables. These logical tables and columns are then mapped to the physical tables and columns used by your database management system in a mapping statement that follows the TABLE statement.

Note: If you define a new table, you must define a mapping statement for that table. The Mapping Statement is illustrated at the end of this chapter, followed by an example that combines the TABLE, TABLE_INFO, and mapping statements.

Syntax

TABLE table_name {field value_type field_attributes; [...]}

Arguments

TABLE

Introduces the TABLE statement. Must be uppercase. You must have one TABLE statement for each logical table in the schema.

table_name

The name of the database table, for example, Call_Req. If adding a database table, you can specify any name beginning with a lowercase letter z. (This avoids possible conflict with existing and future CA SDM table names.) If changing an existing table, find the table in one of the .sch files and use the same name.

field

The name of a logical column in the table, for example, id or desc. You must identify each column by name. If adding a table or adding a column to an existing table, you can specify any name beginning with a lowercase letter z; however, field names must not end with the characters “_f.” (This avoids possible conflict with existing and future CA SDM column names.) If changing an existing column, find the column in one of the .sch files and use the same name.

value_type

The field’s data type. Valid values are:

Value

Description

STRING nn

A string that is nn characters long.

INTEGER

A 32-bit number.

LOCAL_TIME

The number of seconds since January 1, 1970. CA SDM automatically reformats this data type to the designated date format, for example:
mm/dd/yy hh:mm:ss.

DURATION

A period of time, measured in seconds.

REAL

A floating point number

UUID

A 16 byte binary value.

field_attributes

A description of the field. Valid values are:

Value

Description

KEY

Identifies this field as the primary key to be used for identifying records to be updated with pdm_load. This is used if the default primary key, id, is not specified. Must be specified if the field is the primary key in the table.

NOT_NULL

Indicates that the field must contain a value. Must be specified if the field is the primary key in the table. Optional if the field is not the primary key.

REF other_table_name

Indicates that the field references another table. Optional whether the field is the primary key or not.

S_KEY

Optionally identifies this field as the secondary key to be used for identifying records to be updated with pdm_load.

UNIQUE

Indicates that the values in the field must be unique. Must be specified if the field is the primary key in the table. Optional if the field is not the primary key.

Macros are synonyms that will be converted during configuration to the value the macro represents. You can use macros for either data types or attributes. If you wish to use macros, you must add in #include statement to include the file that defines the macro including the path name (usually relative to your schema file). The include statement must be defined prior to using the macro. Example of an include statement:

#include "../schema.mac"

The following are some of the macros defined in .mac files located in the $ NX_ROOT/site (UNIX) or installation-directory/site (Windows) directory.

Data Type

Equivalent

nn

NOT_NULL

uniq

UNIQUE NOT_NULL

ADDR_LINE

STRING 30

EMAILADDR

STRING 120

ENT_DESC

STRING 40

ENT_NAME

STRING 30

OSI_NAME

STRING 80

OSI_TYPE_STRING

STRING 60

USERID

STRING 85

PHONENUM

STRING 32

SYMBOL

STRING 12

HIER_SYM

STRING 60

LONG_SYM

STRING 30

COMMENT

STRING 1000

LONG_STR

STRING 500

LONG_DESC

STRING 240

BOOL

INTEGER

Examples

This TABLE statement in the database schema defines severities. The macro nn indicates that a value is required in the del field. The macro uniq indicates that values are required and must be unique:

#include :../schema.mac”
TABLE Severity {
   id        INTEGER uniq KEY;    // key id
   del       INTEGER nn;          // 0=present,1=gone
   sym       SYMBOL uniq S_KEY; // type symbol
   desc      ENT_DESC;            // non‑OSI specified column
}

This modified TABLE statement makes the Priority field on the Request Detail window required:

TABLE Call_Req {priority INTEGER NOT_NULL;}

This TABLE statement adds a resolution code field to the Call_Req table. The content of the field is numeric and references the Resolution_Code table. This reference allows users to double‑click the Resolution Code field on the Request Detail window to display the values in the Resolution_Code table:

TABLE Call_Req {zres_code INTEGER REF Resolution_Code;}