STR function [String]

Function

Returns the string equivalent of a number.

Syntax

STR ( numeric-expression [, length [, decimal ] ] )

Parameters

numeric-expression Any approximate numeric (float, real, or double precision) expression.

length The number of characters to be returned (including the decimal point, all digits to the right and left of the decimal point, the sign, if any, and blanks). The default is 10 and the maximum length is 255.

decimal The number of digits to the right of the decimal point to be returned. The default is 0.

Examples

The following statement returns a string of six spaces followed by 1234, for a total of ten characters:

SELECT STR( 1234.56 ) FROM iq_dummy

The following statement returns the result 1234.5:

SELECT STR( 1234.56, 6, 1 ) FROM iq_dummy

Usage

If the integer portion of the number cannot fit in the length specified, then the result is NULL. For example, the following statement returns NULL:

SELECT STR( 1234.56, 3 ) FROM iq_dummy

Standards and compatibility