The ZONED function returns a zoned decimal representation.
Numeric to Zoned Decimal
>>-ZONED--------------------------------------------------------> >--(--numeric-expression--+--------------------------------------------+--)->< '-,--precision-integer--+------------------+-' '-,--scale-integer-'
String to Zoned Decimal
>>-ZONED--------------------------------------------------------> >--(--string-expression--+------------------------------------------------------+--)->< '-,--precision--+------------------------------------+-' '-,--scale--+----------------------+-' '-,--decimal-character-'
The default for precision depends on the data type of the numeric-expression:
31 for decimal floating point
The result is the same number that would occur if the first argument were assigned to a decimal column or variable with a precision of precision and a scale of scale. An error is returned if the number of significant decimal digits required to represent the whole part of the number is greater than precision-scale. If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
The result is the same number that would result from CAST(string-expression AS NUMERIC(precision,scale)). Digits are truncated from the end if the number of digits to the right of the decimal-character is greater than the scale s. An error is returned if the number of significant digits to the left of the decimal-character (the whole part of the number) in string-expression is greater than precision-scale. The default decimal separator character is not valid in the substring if the decimal-character argument is specified.
The result of the function is a zoned decimal number with precision of precision and scale of scale. If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
Syntax alternatives: The CAST specification should be used to increase the portability of applications when the precision is specified. For more information, see CAST specification.
SELECT ZONED(:Z1,15,14) FROM SYSIBM.SYSDUMMY1Returns the value 1.12300000000000.
SELECT ZONED(:Z1,11,2) FROM SYSIBM.SYSDUMMY1Returns the value 1123.00.
SELECT ZONED(:Z1,4) FROM SYSIBM.SYSDUMMY1Returns the value 1123.