The VARGRAPHIC function returns a graphic-string representation.
Decimal to Vargraphic
>>-VARGRAPHIC---------------------------------------------------> >--(--decimal-expression--+----------------------+--)---------->< '-,--decimal-character-'
Floating-point to Vargraphic
>>-VARGRAPHIC---------------------------------------------------> >--(--floating-point-expression--+----------------------+--)--->< '-,--decimal-character-'
Decimal floating-point to Vargraphic
>>-VARGRAPHIC---------------------------------------------------> >--(--decimal-floating-point-expression--+----------------------+--)->< '-,--decimal-character-'
Character to Vargraphic
>>-VARGRAPHIC--(--character-expression--------------------------> >--+--------------------------------+--)----------------------->< '-,--+-length--+--+------------+-' '-DEFAULT-' '-,--integer-'
Graphic to Vargraphic
>>-VARGRAPHIC--(--graphic-expression----------------------------> >--+--------------------------------+--)----------------------->< '-,--+-length--+--+------------+-' '-DEFAULT-' '-,--integer-'
The result of the function is a varying-length graphic string (VARGRAPHIC).
If the first argument can be null, the result can be null. If the first argument is null, the result is the null value. If the first argument is an empty string or the EBCDIC string X'0E0F', the result is an empty string.
The result is a varying-length graphic string of the argument in the form of an SQL integer constant. The result consists of n characters that are the significant digits that represent the value of the argument with a preceding minus sign if the argument is negative. It is left justified.
The actual length of the result is the smallest number of characters that can be used to represent the value of the argument. Leading zeroes are not included. If the argument is negative, the first character of the result is a minus sign. Otherwise, the first character is a digit or the decimal-character.
The CCSID of the result is 1200 (UTF-16).
The result is a varying-length graphic string representation of the argument. The result includes a decimal character and up to p digits, where p is the precision of the decimal-expression with a preceding minus sign if the argument is negative. Leading zeros are not returned. Trailing zeros are returned.
The length attribute of the result is 2+p where p is the precision of the decimal-expression. The actual length of the result is the smallest number of characters that can be used to represent the result, except that trailing characters are included. Leading zeros are not included. If the argument is negative, the result begins with a minus sign. Otherwise, the result begins with a digit or the decimal-character.
The CCSID of the result is 1200 (UTF-16).
The result is a varying-length graphic string representation of the argument in the form of a floating-point constant.
The length attribute of the result is 24. The actual length of the result is the smallest number of characters that can represent the value of the argument such that the mantissa consists of a single digit other than zero followed by the decimal-character and a sequence of digits. If the argument is negative, the first character of the result is a minus sign; otherwise, the first character is a digit or the decimal-character. If the argument is zero, the result is 0E0.
The CCSID of the result is 1200 (UTF-16).
The result is a varying-length graphic string representation of the argument in the form of a decimal floating-point constant.
The length attribute of the result is 42. The actual length of the result is the smallest number of characters that represents the value of the argument, including the sign, digits, and decimal-character. Trailing zeros are significant. If the argument is negative, the first character of the result is a minus sign; otherwise, the first character is a digit or the decimal-character. If the argument is zero, the result is 0.
If the DECFLOAT value is Infinity, sNaN, or NaN, the strings 'INFINITY', 'SNAN', and 'NAN', respectively, are returned. If the special value is negative, a minus sign will be the first character in the string. The DECFLOAT special value sNaN does not result in an exception when converted to a string.
The CCSID of the result is 1200 (UTF-16).
If the second argument is not specified, or if DEFAULT is specified, the length attribute of the result is the same as the length attribute of the first argument, except if the expression is an empty string or the EBCDIC string X'0E0F', the length attribute of the result is 1.
The actual length of the result is the minimum of the length attribute of the result and the actual length of character-expression. Each character of the argument determines a character of the result. If the length (in characters) of the character-expression is greater than the length attribute of the result, truncation is performed. A warning (SQLSTATE 01004) is returned unless the truncated characters were all blanks.
If integer is not specified then the CCSID of the result is determined by a mixed CCSID. Let M denote that mixed CCSID.
In the following rules, S denotes one of the following:
M is determined as follows:
The following table summarizes the result CCSID based on M.
| M | Result CCSID | Description | DBCS Substitution Character |
|---|---|---|---|
| 930 | 300 | Japanese EBCDIC | X'FEFE' |
| 933 | 834 | Korean EBCDIC | X'FEFE' |
| 935 | 837 | S-Chinese EBCDIC | X'FEFE' |
| 937 | 835 | T-Chinese EBCDIC | X'FEFE' |
| 939 | 300 | Japanese EBCDIC | X'FEFE' |
| 5026 | 4396 | Japanese EBCDIC | X'FEFE' |
| 5035 | 4396 | Japanese EBCDIC | X'FEFE' |
The equivalence of SBCS and DBCS characters depends on M. Regardless of the CCSID, every double-byte code point in the argument is considered a DBCS character, and every single-byte code point in the argument is considered an SBCS character with the exception of the EBCDIC mixed data shift codes X'0E' and X'0F'.
If the second argument is not specified, or if DEFAULT is specified, the length attribute of the result is the same as the length attribute of the first argument, except if the expression is an empty string, the length attribute of the result is 1.
The actual length of the result is the minimum of the length attribute of the result and the actual length of graphic-expression. Each character of the argument determines a character of the result. If the length (in characters) of the graphic-expression is greater than the length attribute of the result, truncation is performed. A warning (SQLSTATE 01004) is returned unless the truncated characters were all blanks.
If integer is not specified then the CCSID of the result is the CCSID of the first argument.
Syntax alternatives: The CAST specification should be used to increase the portability of applications when the first argument is a string and the length attribute is specified. For more information, see CAST specification.
SELECT VARGRAPHIC(FIRSTNME) INTO :VAR_DESC FROM EMPLOYEE WHERE EMPNO = '000050'