Numeric to Zoned Decimal
>>-ZONED--------------------------------------------------------> >--(--numeric-expression--+--------------------------------------------+--)->< '-,--precision-integer--+------------------+-' '-,--scale-integer-'
String to Zoned Decimal
>>-ZONED--------------------------------------------------------> >--(--string-expression--+------------------------------------------------------+--)->< '-,--precision--+------------------------------------+-' '-,--scale--+----------------------+-' '-,--decimal-character-'
The ZONED function returns a zoned decimal representation of:
The result of the function is a zoned decimal number with precision of p and scale of s, where p and s are the second and third arguments. If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
Numeric to Zoned Decimal
The default for precision depends on the data type of the numeric-expression:
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 p and a scale of s. An error is returned if the number of significant decimal digits required to represent the whole part of the number is greater than p-s.
String to Zoned Decimal
If the argument is a string-expression, the result is the same number that would result from CAST( string-expression AS NUMERIC(precision, scale)). Leading and trailing blanks are eliminated and the resulting string must conform to the rules for forming a floating-point, integer, or decimal constant. If the whole part of the argument is not within the range of decimal with the specified precision, an error is returned. Any fractional part of the argument is truncated.
The result is the same number that would result from CAST(string-expression AS NUMERIC(p,s)). 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 p-s. The default decimal separator character is not valid in the substring if the decimal-character argument is specified.
Syntax alternatives: When the precision is specified, the CAST specification should be used for maximal portability. 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.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.