DB2 Scalar functions - GRAPHIC
The GRAPHIC function returns a fixed-length graphic string representation of a value of a different data type.
The schema is SYSIBM. The function name cannot be specified as a qualified name when keywords are used in the function signature.
The result is a fixed-length graphic string representation of integer-expression in the form of an SQL integer constant. The result consists of n double-byte characters, which represent the significant digits in the argument, and is preceded by a minus sign if the argument is negative. The result is left-aligned.
The code page of the result is the DBCS code page of the section.
The result is a fixed-length graphic string representation of decimal-expression in the form of an SQL decimal constant. The length of the result is 2+p, where p is the precision of decimal-expression. Leading zeros are not included. Trailing zeros are included. If decimal-expression is negative, the first double-byte character of the result is a minus sign; otherwise, the first double-byte character is a digit or the decimal character. If the scale of decimal-expression is zero, the decimal character is not returned. If the number of double-byte characters in the result is less than the defined length of the result, the result is padded on the right with blanks.
The result is a fixed-length graphic string representation of floating-point-expression in the form of an SQL floating-point constant. The length of the result is 24. If floating-point-expression is negative, the first double-byte character of the result is a minus sign; otherwise, the first double-byte character is a digit. If floating-point-expression is zero, the result is 0E0. If the number of double-byte characters in the result is less than 24, the result is padded on the right with blanks.
The result is a fixed-length graphic string representation of decimal-floating-point-expression in the form of an SQL decimal floating-point constant. The length attribute of the result is 42. The result is the smallest number of double-byte characters that can represent the value of decimal-floating-point-expression. If decimal-floating-point-expression is negative, the first double-byte character of the result is a minus sign; otherwise, the first double-byte character is a digit. If decimal-floating-point-expression is zero, the result is 0.
If the value of decimal-floating-point-expression is the special value Infinity, sNaN, or NaN, the strings G'INFINITY', G'SNAN', and G'NAN', respectively, are returned. The decimal floating-point special value sNaN does not result in a warning when converted to a string. If the number of double-byte characters in the result is less than 42, the result is padded on the right with blanks.
If the second argument is not specified:
The result is a fixed-length graphic string that is converted from character-expression. The length attribute of the result is determined by the value of integer.
The actual length of the result is the same as the length attribute of the result.
If the length of character-expression that is converted to a graphic string is less than the length attribute of the result, the result is padded with blanks up to the length attribute of the result.
If the length of character-expression that is converted to a graphic string is greater than the length attribute of the result, several scenarios exist:
For details about the conversion process, see VARGRAPHIC scalar function.
The result is a fixed-length graphic string that is converted from character-expression. The length attribute of the result is the minimum of the length attribute of character-expression and the maximum length for the GRAPHIC data type.
The actual length of the result is the same as the length attribute of the result. If the length of character-expression that is converted to a graphic string is less than the length attribute of the result, the result is padded with blanks up to the length attribute of the result. If the length of character-expression that is converted to a graphic string is greater than the length attribute of the result, an error is returned (SQLSTATE 22001).
The result is a fixed-length graphic string. The length attribute of the result is determined by the value of integer.
If the length of graphic-expression is less than the length attribute of the result, the result is padded with blanks up to the length attribute of the result.
If the length of graphic-expression is greater than the length attribute of the result, several scenarios exist:
The code page of the string is the code page of the section.
The GRAPHIC function returns a fixed-length graphic string representation of:
In a non-Unicode database, the string units of the result is double bytes. Otherwise, the string units of the result are determined by the data type of the first argument.
If the first argument can be null, the result can be null; if the first argument is null, the result is the null value.
SELECT GRAPHIC(EDLEVEL) FROM EMPLOYEE WHERE> LASTNAME = 'HAAS'
SELECT GRAPHIC(SALARY + COMM, ',') FROM EMPLOYEE WHERE LASTNAME = 'HAAS'
values GRAPHIC(3=3)
values GRAPHIC(3>3)