NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
P-13
Considerations—Parameters
?[param-name]
specifies a parameter and, optionally, a name for the parameter. The name must be
an SQL identifier.
[ INDICATOR ] ?[indicator-param]
specifies an indicator parameter to use for inserting null values into the database
through the parameter, or for handling null values that might be returned to the
parameter in host programs. (An indicator parameter with a value less then 0
indicates a null value; an indicator parameter with a value of 0 indicates a non null
value.)
An indicator parameter has the same format as the parameter to which it is attached.
For details on handling null values in dynamic SQL programs, see the NonStop
SQL/MP programming manual for your host language.
TYPE AS { DATETIME [start-dt TO] end-dt }
{ DATE }
{ TIME }
{ TIMESTAMP }
{ INTERVAL start-dt }
{ [ (start-field-precision) ] }
{ [ TO end-dt ] }
tells SQL to expect the value entered for the parameter to be a value of the specified
date-time or INTERVAL data type. (You cannot use TYPE AS to specify a character
or numeric data type for a parameter. Use the CAST function instead.)
A value for a parameter declared with a TYPE AS clause must have a character data
type and must be associated with a single-byte character set or the UNKNOWN
character set.
For example, the following statements insert the character value in ?BIRTHDAY
into a table as a DATE value:
SET PARAM ?BIRTHDAY "1989-07-31";
INSERT INTO =EMPLOYEES (BIRTHDATE)
VALUES (?BIRTHDAY TYPE AS DATE);
If the name of a DATETIME or INTERVAL parameter occurs more than once in a
single SQL statement, each occurrence must include an identical TYPE AS clause.
Considerations—Parameters
Unnamed parameters
You can use an unnamed parameter only in a prepared DML statement. The
unnamed parameter—a question mark (?) by itself—is always a distinct parameter
even when it occurs multiple times in a statement. When you execute a statement