SQL Programming Manual for TAL
Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL—527887-001
2-17
Using Indicator Variables for Null Values
format you want and retrieving the value using the DATEFORMAT function. You should
declare the host variable size to be consistent with the format you will use.
If you use the INVOKE directive to generate host variables from an SQL table
definition, you can specify the DATEFORMAT clause to create host variables of the
appropriate size. For more examples of the INVOKE directive, see Section 3, NonStop
SQL Statements and Directives.
Using Indicator Variables for Null Values
An indicator variable is a 2-byte integer variable defined in the Declare Section. An
indicator variable is always associated with a host variable and is used to indicate
whether a column can (or does) contain a null value. A null value in a column means
that a value is either unknown for the row or does not apply to the row.
When sending a value to NonStop SQL, a program sets the indicator variable to:
•
Less than zero (0) for a null value
•
Zero (0) for a nonnull value
When 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 that allow
null values. If SQL columns can contain null values, a program should use indicator
variables when referring to those columns. For example, a program might:
•
Insert null values into the database with an INSERT or UPDATE statement
•
Retrieve null values from the database with a SELECT statement
•
Specify null values in an INSERT, UPDATE, DELETE, or SELECT statement
You can also use indicator variables with the INSERT, UPDATE, DELETE, and
SELECT statements. You can use the keyword NULL, as shown in the subsequent
examples in this section.