SQL/MP Programming Manual for COBOL

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL529758-003
2-19
Date-Time and INTERVAL Data Types
does not generate a SYSKEY host variable. (INVOKE does not generate a column for
the SYSKEY of a table because SYSKEY cannot be specified in a CREATE TABLE
statement.)
For example, suppose that you create a table by using this statement:
CREATE TABLE TYPESTAB (COLUMN-A INT, COLUMN-B INT)
INVOKE generates host variables for columns COLUMN-A and COLUMN-B but does
not generate a host variable for the SYSKEY automatically associated with the table.
However, suppose that you create a view from the base table with a column
corresponding to the table's SYSKEY:
CREATE VIEW AVIEW (COLUMN-X, COLUMN-Y, COLUMN-Z)
AS SELECT SYSKEY, COLUMN-A, COLUMN-B
FROM TYPESTAB
INVOKE generates host variables for columns COLUMN-X, COLUMN-Y, and
COLUMN-Z because these columns are included in the view definition.
If the view definition does not specifically include the SYSKEY column, INVOKE does
not generate a host variable for SYSKEY as shown in the next example:
CREATE VIEW AVIEW
AS SELECT * FROM TYPESTAB
INVOKE generates host variables for only COLUMN-A and COLUMN-B because a
SYSKEY column was not included in the view definition. The SELECT * statement acts
in the same manner as an INVOKE directive, that is, it only selects columns explicitly
specified in a CREATE statement.
Date-Time and INTERVAL Data Types
In an INVOKE directive, use the DATEFORMAT clause to specify the format of
date-time (DATETIME, DATE, TIME, TIMESTAMP) or INTERVAL columns. SQL/MP
converts the columns to character fields.
The size of each character field is determined by the size of the range of the fields
defined for the data type. For example, if the range of fields for the column is YEAR TO
DAY, the field in the invoked record description is 10 characters wide. Some examples
follow.
DATE Representation
Suppose that an SQL table has these column definitions:
NAME CHAR(18)
BIRTH_DATE DATE
Figure 2-1
on page 2-20 illustrates how a date is represented. The date is May 28,
1952.