SQL Programming Manual for Pascal
Host Variables and Parameters
HP NonStop SQL Programming Manual for Pascal—528614-001
2-10
Using Host Variables
TYPE AS DATE
TYPE AS TIME
TYPE AS TIMESTAMP
TYPE AS INTERVAL YEAR
You can also use date-time and INTERVAL literals. For example, to insert a date-time
or INTERVAL value using a literal into TABLE:
EXEC SQL INSERT INTO TABLE (START_DATE )
VALUES DATE "1990-03-21";
Or, to insert the value using a host variable:
{ Variable declarations: }
EXEC SQL BEGIN DECLARE SECTION;
DATEVAR : FSTRING(9) ;
EXEC SQL END DECLARE SECTION;
...
{ Executable code }
{ Copy "1990-03-21" into DATEVAR }
...
EXEC SQL INSERT INTO table (START_DATE)
VALUES :DATEVAR TYPE AS DATE;
Using Indicator Variables for Null Values
You can use a null value in a column to indicate that a value is either unknown for the
row or is not applicable to the row. For more information about null values, see the
SQL/MP Reference Manual.
An indicator variable is a 2-byte integer variable defined in the Declare Section. The
indicator variable is always associated with a host variable.
To send a value to NonStop SQL for insertion, update, or comparison, a program sets
the indicator variable to:
•
Less than zero (0) for a null value
•
Zero (0) for a nonnull value
When it is returning a value to a program, NonStop SQL sets the indicator variable to:
•
Less than zero (0) for a null value
•
Zero (0) for a nonnull value
The INVOKE directive automatically declares indicator variables for columns defined to
allow null values.