Graphic strings

A graphic string is a sequence of double-byte characters. The length of the string is the number of its characters. Like character strings, graphic strings can be empty.

Fixed-length graphic strings

When fixed-length graphic-string distinct types, columns, and variables are defined, the length attribute is specified and all values have the same length. For a fixed-length graphic string, the length attribute must be between 1 through 16 383 inclusive. See SQL limits for more information.

Varying-length graphic strings

  • The types of varying-length graphic strings are:
  • VARGRAPHIC
  • DBCLOB

A Double-Byte Character Large OBject (DBCLOB) column is useful for storing large amounts of double-byte character data, such as documents written using a double-byte character set.

Distinct types, columns, and variables all have length attributes. When varying-length graphic-string distinct types, columns, and variables are defined, the maximum length is specified and this becomes the length attribute. Actual values may have a smaller length. For a varying-length graphic string, the length attribute must be between 1 through 16 370 inclusive. For a DBCLOB string, the length attribute must be between 1 through 1 073 741 823 inclusive. See SQL limits for more information.

For the restrictions that apply to the use of long varying-length strings, see Limitations on use of strings.

Graphic-string variables

  • Fixed-length graphic-string variables can be defined in C, C++, ILE COBOL, and ILE RPG. (In C and C++, fixed-length graphic-string variables are limited to a length of 1.)

    Although fixed-length graphic-string variables cannot be defined in PL/I, COBOL/400, and RPG/400®, a character-string variable will be treated like a fixed-length graphic-string variable if it was generated in the source from a GRAPHIC column in the external definition of a file.

  • VARGRAPHIC varying-length graphic-string variables can be defined in C, C++, ILE COBOL, REXX, and ILE RPG.
    • In REXX and ILE RPG, there is a varying-length graphic-string data type.
    • In C, C++, and ILE COBOL, varying-length graphic strings are represented as structures.
    • In C and C++, varying-length graphic-string variables can also be represented by NUL-terminated graphic strings.
    • Although varying-length graphic-string variables cannot be defined in PL/I, COBOL/400, and RPG/400, a character-string variable will be treated like a varying-length graphic-string variable if it was generated in the source from a VARGRAPHIC column in the external definition of a file.
  • DBCLOB varying-length character-string variables can be defined in all host languages except REXX, RPG/400, and COBOL/400.
    • In ILE RPG, a DBCLOB varying-length character string is declared using the SQLTYPE keyword.
    • In all other languages, an SQL TYPE IS DBCLOB clause is used.