SMALLINT scalar function
The SMALLINT function returns a small integer (a binary integer with a precision of 15 bits) representation of a value of a different data type.
Numeric to SMALLINT
String to SMALLINT
Boolean to SMALLINT
The schema is SYSIBM.
 Numeric to SMALLINT

 numericexpression
 An expression that returns a value of any builtin numeric data type.
The result is the same number that would occur if the argument were assigned to a small integer column or variable. The fractional part of the argument is truncated. If the whole part of the argument is not within the range of small integers, an error is returned (SQLSTATE 22003).
 String to SMALLINT

 stringexpression
 An expression that returns a value that is a characterstring or Unicode
graphicstring representation of a number with a length not greater than the maximum length of
a character constant.
The result is the same number that would result from CAST(stringexpresssion AS SMALLINT). Leading and trailing blanks are eliminated and the resulting string must conform to the rules for forming an integer, decimal, floatingpoint, or decimal floatingpoint constant (SQLSTATE 22018). If the whole part of the argument is not within the range of small integers, an error is returned (SQLSTATE 22003). The data type of stringexpression must not be CLOB or DBCLOB (SQLSTATE 42884).
 Boolean to SMALLINT

 booleanexpression
 An expression that returns a Boolean value (TRUE or FALSE). The result is either 1 (for TRUE) or 0 (for FALSE).
Result
The result of the function is a small integer. If the argument can be null, the result can be null; if the argument is null, the result is the null value.
Notes
 Increasing portability of applications: If the first argument is numeric, or if the first argument is a string and the length argument is specified, use the CAST specification instead of this function to increase the portability of your applications.
Examples
 Example 1: Using the EMPLOYEE table, select a list containing salary (SALARY) divided by
education level (EDLEVEL). Truncate any decimal in the calculation. The list should also contain the
values used in the calculation and the employee number (EMPNO).
SELECT SMALLINT(SALARY / EDLEVEL), SALARY, ESDLEVEL, EMPNO FROM EMPLOYEE
 Example 2: The following
statement returns the value 1 of data type
SMALLINT.
values SMALLINT(TRUE)
 Example 3: The following
statement returns the value 0 of data type
SMALLINT.
values SMALLINT(3>3)