SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-26
INVOKE
! STRING wait^time[0:2]; ! An extra byte is generated
! for a possible sign
! END;
! Declare storage for the table:
STRUCT .projects^rec(projects^type);
! Procedure code:
EXEC SQL
SELECT project^name, start^date, end^date, wait^time
INTO
:projects^rec.project^name,
:projects^rec.start^date TYPE AS DATETIME YEAR TO MINUTE,
:projects^rec.end^date TYPE AS DATETIME YEAR TO MINUTE,
:projects^rec.wait^time TYPE AS INTERVAL DAY(2)
FROM =projects
WHERE project^name = "995";
...
Inserting Date-Time and INTERVAL Values. In this example, date-time (DATE) and
INTERVAL values are inserted into the BILLINGS table. The SQL definition is shown at
the beginning of the example.
The SQL definition for the billings table is:
! CUSTNUM CHAR (4) NOT NULL
! START_DATE DATE NOT NULL
! BILLING_DATE DATE NOT NULL
! TIME_BEFORE_PMT INTERVAL DAY(3) NOT NULL
! Variable declarations:
EXEC SQL BEGIN DECLARE SECTION;
...
STRUCT .billings;
BEGIN
STRING custnum[0:3];
STRING start^date[0:9];
STRING billing^date[0:9];
STRING time^before^pmt[0:3]; ! An extra byte is used
! for a possible sign
END;
EXEC SQL END DECLARE SECTION;
...