SQL/MX 2.x Reference Manual (H06.04+)

SQL/MX Language Elements
HP NonStop SQL/MX Reference Manual540440-003
6-73
MXCI Parameters
MXCI Parameters
Examples of MXCI Parameters
Typically, you use parameters (both within MXCI and in embedded SQL) so that you
can prepare an SQL statement and then execute it later, providing different values for
each execution. Within an MXCI file to be obeyed, you can also use parameters for
values so that an SQL statement within the file can execute with different values.
MXCI Named Parameters
You specify a named parameter in a DML statement or a CALL statement within MXCI
as:
?param-name
An MXCI param-name is preceded by a question mark. It begins with an alphabetic or
underscore character and can contain up to 128 alphabetic, numeric, and underscore
characters. Parameter names are case-sensitive. For example, the parameter ?pn is
not equivalent to the parameter ?PN.
Unlike SQL identifiers, you cannot delimit MXCI parameter names with double-quote
characters ("). You can use reserved words. For example, you can use ?at as an
MXCI parameter.
The value of a named parameter is set by using the SET PARAM command.
MXCI Unnamed Parameters
You specify an unnamed parameter in a DML statement or a CALL statement within
MXCI as:
?
The value of an unnamed parameter is set by using the USING clause of the
EXECUTE statement.
Type Assignment for Parameters
The data type of a parameter is either numeric or character. Only character literals
associated with ISO88591 can be used for MXCI parameters. If the data type of the
target column is either datetime or interval, you must convert (by using CAST) the
parameter to the data type of the target column.
If the parameter and target column has numeric data type, NonStop SQL/MX treats
the parameter as DECIMAL(n), where n is the number of digits in the parameter
value.
If the parameter and target column has character data type, NonStop SQL/MX
treats the parameter as CHAR(n), where n is the number of bytes in the parameter
value.