Description
Returns character data converted from numeric data. The character data is right-justified, with a specified length and decimal precision. ().
Sample Source Pattern
Syntax
STR ( float_expression [ , length [ , decimal ] ] )
STR_UDF( numeric_expression, number_format )
Arguments
numeric_expression
: Float expression with a decimal point.
length
(Optional): Length that the returning expression will have, including point notation, decimal, and float parts.
decimal
(Optional): Is the number of places to the right of the decimal point.
Return Type
VARCHAR
.
Examples
Input:
/* 1 */
SELECT STR(123.5);
/* 2 */
SELECT STR(123.5, 2);
/* 3 */
SELECT STR(123.45, 6);
/* 4 */
SELECT STR(123.45, 6, 1);
Output:
1) 124
2) **
3) 123
4) 123.5
Input:
/* 1 */
SELECT
PUBLIC.STR_UDF(123.5, '99999');
/* 2 */
SELECT
PUBLIC.STR_UDF(123.5, '99');
/* 3 */
SELECT
PUBLIC.STR_UDF(123.45, '999999');
/* 4 */
SELECT
PUBLIC.STR_UDF(123.45, '9999.9');
Output:
1) 124
2) ##
3) 123
4) 123.5