SQL Programming Manual for Pascal
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal—528614-001
3-24
Handling Columns of Date-Time and INTERVAL
Types
CITY : FSTRING(14);
STATE : FSTRING(12);
POSTCODE : FSTRING(10);
CREDIT : FSTRING(2);
END;
Your program must now declare storage for the record. The variable CUSTOMER has
the TYPE definition generated by INVOKE:
VAR CUSTOMER : CUST_TYPE;
The following example shows a sample CREATE TABLE statement for an employee
table. The example also shows a sample INVOKE statement and the generated record
description, which includes indicator variables.
Sample CREATE TABLE statement for the table that is invoked:
CREATE TABLE $VOL.PERSNL.EMPLOYEE
( NAME CHAR(20) NOT NULL,
NICKNAME CHAR(20),
DEPARTMENT VARCHAR(30) NOT NULL,
MANAGER VARCHAR(30) );
Sample INVOKE statement as it would appear in a program:
{ Variable declarations: }
EXEC SQL
INVOKE EMPLOYEE;
Generated record description in Pascal; note that because NICKNAME and
MANAGER can be null, INVOKE generates indicator variables for them:
{* Record Definition for table \SYS.$VOL.SUBVOL.EMPLOYEE *}
{* Definition current at 14:55:47 - 05/10/90 *}
type
employee_type = record
name : fstring(20);
nickname_i : int16;
nickname : fstring(20);
department : string(30);
manager_i : int16;
manager : string(30);
end;
Handling Columns of Date-Time and INTERVAL Types
When you invoke a column with a date-time or INTERVAL data type, the data is
represented as a character field whose size is determined by the range information in
the date-time or INTERVAL column. You control the display format by inserting the
value in the format you want and retrieving the value using the DATEFORMAT
function. If you use INVOKE to generate host variables from an SQL table definition,
you can specify the DATEFORMAT clause to create host variables of the appropriate
size.