SQL Programming Manual for TAL
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL—527887-001
3-25
INVOKE
INTERVAL values are represented as character strings with a separator between the
values of the fields (year-month or day-time). An extra byte is generated at the
beginning of the INTERVAL string for a sign.
The default representations for date-time and INTERVAL values are shown in these
subsections.
Date-Time Representation. The column definitions in the SQL table are:
name CHAR(18)
birth_date DATETIME
The date represented is May 28, 1952:
The structure definition in the TAL program is:
STRUCT employee^rec;
BEGIN
STRING name[0:17];
STRING birth^date[0:9];
END;
The host variable reference is:
:age TYPE AS INTERVAL YEAR(2) TO MONTH
These examples use host variables with date-time and INTERVAL values. Appendix B
also includes a program that uses date-time and INTERVAL values.
Selecting Date-Time and INTERVAL Values. In this example, a table named
PROJECTS is invoked from a database. The table has this SQL definition:
PROJECT_NAME PIC X(10)
START_DATE DATETIME YEAR TO MINUTE
END_DATE DATETIME YEAR TO MINUTE
WAIT_TIME INTERVAL DAY(2)
This example uses a TACL DEFINE named =PROJECTS for the table. The structure
that appears in the program is shown after the INVOKE directive.
EXEC SQL BEGIN DECLARE SECTION;
...
EXEC SQL INVOKE =projects;
! The following template is inserted at compile time:
! STRUCT projects^type(*);
! BEGIN
! STRING project^name[0:9];
! STRING start^date[0:15];
! STRING end^date[0:15];
Year Separator Month Separator Day Null
195 2 - 0 5 - 2 8