SQL Programming Manual for TAL

NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for TAL527887-001
3-22
INVOKE
The example uses the JULIANTIMESTAMP and CONVERTTIMESTAMP Guardian
procedures and the CONVERTTIMESTAMP SQL function. To call Guardian
procedures, include the declarations from the EXTDECS file.
?SOURCE $SYSTEM.SYSTEM.EXTDECS ( JULIANTIMESTAMP,
CONVERTTIMESTAMP)
EXEC SQL BEGIN DECLARE SECTION;
FIXED dtvar; ! Variable for storing the timestamp value
EXEC SQL END DECLARE SECTION;
INT SQLCODE;
...
PROC driver MAIN ;
BEGIN
! Get current Julian timestamp in Greenwich mean time:
dtvar := JULIANTIMESTAMP();
! Convert timestamp to local time:
dtvar := CONVERTTIMESTAMP(dtvar);
! Insert value into table using SQL CONVERTTIMESTAMP:
EXEC SQL BEGIN WORK;
EXEC SQL INSERT INTO table^t (column^a)
VALUES ( CONVERTTIMESTAMP (:dtvar) );
EXEC SQL COMMIT WORK;
END;
INVOKE
The INVOKE directive defines a TAL structure template with fields and data types that
correspond one to one with the columns in an SQL table or view. INVOKE writes a TAL
data description for each column in the table or view.
Use INVOKE to create:
Host variables in a Declare Section that correspond to the columns in a table Indicator
variables that indicate whether a column value contains (or can contain) a null value
Follow these guidelines when you use the INVOKE directive:
Use the INVOKE directive only in the variable declarations; do not use it with
executable statements.
To use the INVOKE directive on a table or view, you must have read access to the
table or view when you compile your program.
For the best performance, use INVOKE to define host variables that serve as input
or output variables for database columns. INVOKE defines the host variables so
that data conversion is not required at run time. For more information see Creating
Host Variables With the INVOKE Directive on page 2-20, in Section 2, Host
Variables and Parameters.