Neoview Command Interface (NCI) Guide (R2.4)

Named parameter (represented by ?param-name) in a DML statement or in a prepared
SQL statement
Unnamed parameter (represented by ?) in a prepared SQL statement only
A prepared statement is one that you SQL compile by using the PREPARE statement. For more
information about PREPARE, see the Neoview SQL Reference Manual.
After running SET PARAM commands in the session:
You can specify named parameters (?param-name) in a DML statement.
You can execute a prepared statement with named parameters by using the EXECUTE
statement without a USING clause.
You can execute a prepared statement with unnamed parameters by using the EXECUTE
statement with a USING clause that contains literal values and/or a list of the named
parameters set by SET PARAM.
The EXECUTE statement substitutes parameter values for the parameters in the prepared
statement. For more information about EXECUTE, see the Neoview SQL Reference Manual.
Syntax
SET PARAM param-name param-value
param-name
is the name of the parameter for which a value is specified. Parameter names are case-sensitive.
For example, the parameter ?pn is not equivalent to the parameter ?PN. param-name can
be preceded by a question mark (?), such as ?param-name.
param-value
is a numeric or character literal that specifies the value for the parameter. If you do not specify
a value, NCI returns an error.
If param-value is a character literal and the target column type is a character string, you do
not have to enclose the value in single quotation marks. Its data type is determined from the
data type of the column to which the literal is assigned. Character strings specified as
parameter values are always case-sensitive even if they are not enclosed in quotation marks.
Considerations
You must enter the command on one line. The command does not require an SQL terminator.
You can execute this command only in SQL mode.
Use separate SET PARAM commands to name and assign values to each unique parameter
in a prepared SQL statement before running the EXECUTE statement.
Parameter names are case-sensitive. If you specify a parameter name in lowercase in the
SET PARAM command, you must specify it in lowercase in other statements, such as DML
statements or EXECUTE.
The name of a named parameter (?param-name) in a DML statement must be identical to
the parameter name (param-name) that you specify in a SET PARAM command.
Examples
This command sets a value for the ?sal (salary) parameter:
SQL>set param ?sal 40000.00
This command sets a character string value, GREEN, for the ?lastname parameter:
SQL>set param ?lastname GREEN
These commands set values for named parameters in a subsequent SELECT statement:
SQL>set param ?sal 80000.00
SQL>set param ?job 100
126 NCI Commands