ZONED

Click to skip syntax diagram

Numeric to Zoned Decimal

Read syntax diagramSkip visual syntax diagram>>-ZONED-------------------------------------------------------->
 
>--(--numeric-expression--+--------------------------------------------+--)-><
                          '-,--precision-integer--+------------------+-'
                                                  '-,--scale-integer-'
 

String to Zoned Decimal

Read syntax diagramSkip visual syntax diagram>>-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

numeric-expression
An expression that returns a value of any built-in numeric data type.
precision
An integer constant with a value greater than or equal to 1 and less than or equal to 63.

The default for precision depends on the data type of the numeric-expression:

scale
An integer constant that is greater than or equal to 0 and less than or equal to precision. If not specified, the default is 0.

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

string-expression
An expression that returns a value that is a character-string or graphic-string representation of a number.

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.

precision
An integer constant that is greater than or equal to 1 and less than or equal to 63. If not specified, the default is 15.
scale
An integer constant that is greater than or equal to 0 and less than or equal to precision. If not specified, the default is 0.
decimal-character
Specifies the single-byte character constant that was used to delimit the decimal digits in string-expression from the whole part of the number. The character must be a period or comma. If the second argument is not specified, the decimal point is the default decimal separator character. For more information, see Decimal point.

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.

Note

Syntax alternatives: When the precision is specified, the CAST specification should be used for maximal portability. For more information, see CAST specification.

Examples