NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
S-37
Considerations—SET PARAM
date cannot be an expression.
Considerations—SET PARAM
Data types for parameters
SQL determines the data type for a parameter based on how you use the parameter
in an SQL statement. As a result, a literal value you assign to a parameter might be
interpreted differently in different SQL statements.
For example, the string “123” assigned to a parameter might be treated as an integer,
a character string, or as an illegal value—depending on whether you use the
parameter in a statement that requires an integer, a character string, or a date-time
value.
Similarly, a parameter that appears to have the value of a string literal with an
associated character set, such as _KANJI”c1c2” (where “c1c2” indicates one
double-byte character) is interpreted as having the following value:
See Parameters
on page P-12 for information about the way SQL determines data
types for parameters. See CAST Function
on page C-4 for information about using
the CAST function to specify a numeric or character data type for a parameter.
Passing parameters to report formatting commands
You cannot use parameters in report formatting commands. A method for using
TACL macros to pass parameters to report formatting commands is described in the
NonStop SQL/MP Report Writer Guide.
Examples—SET PARAM
In the following example, the SELECT statement in the FINDSUP2 file finds
suppliers of a specified part. The suppliers are located in a specified state.
VOLUME $VOL1.INVENT;
SELECT S.SUPPNUM, SUPPNAME FROM SUPPLIER S, PARTSUPP
WHERE S.SUPPNUM = PARTSUPP.SUPPNUM AND
PARTNUM = ?PN AND STATE = ?ST;
hh Hour, from 0 through 23, 1 to 2 digits
nn Minute, from 0 through 59, 1 to 2 digits
ss Second, from 0 through 59, 1 to 2 digits
mss Millisecond, from 0 through 999, 1 to 3 digits
uss Microsecond, from 0 through 999, 1 to 3 digits
c1c2 if the data type is CHAR(2) CHAR SET KANJI
_KANJI”c1c2” if the data type is CHAR(12)
_K if the data type is CHAR(2)