The
primitive type STRING is composed of double-byte UNICODE characters.
You can store the value of the field in a file or database. If your code
interacts with DB2® UDB,
you must ensure that the code page for GRAPHIC data is UNICODE and that the
column that stores the data item value is of SQL data type GRAPHIC or VARGRAPHIC.
For details on Unicode, see the web site of the Unicode Consortium (www.unicode.org).
The following syntax declares a limited-length string, which is a string
that is restricted to a specified number of characters:
varName STRING(lengthLimit);
- varName
- Name of the variable. For details on validity, see Naming conventions.
- lengthLimit
- An integer that represents the number of characters. The value is greater
than zero.
When you specify a limited-length string as a function parameter whose
modifier is OUT or INOUT, the length limit must be the same in argument and
parameter. When you specify a limited-length string as a function parameter
whose modifier is IN, any text input is valid. The following statements apply
to the latter case as well as when you assign a value to a limited-length
string:
- If more characters are in the source than are valid in the target, EGL
runtime truncates the copied content to fit the available length.
- If fewer characters are in the source than are valid in the target, EGL
runtime pads the copied content with blanks, to the specified length.
The following statements apply to comparisons:
- Trailing blanks in fields that are of type STRING (but are not of limited
length) are considered during a comparison.
- Trailing blanks in a limited-length string are ignored during a comparison.
Before the comparison, the other operand (if shorter than the limited-length
field) is padded with blanks or binary zeros up to the number of characters
declared in the field of type limited length.
When you concatenate a limited-length string with another string, the contribution
of the limited-length string depends on the value of build descriptor option itemsNullable.
If the value of that option is YES, the limited-length string is padded with
blanks to the last position specified in the string declaration. Otherwise,
no padding occurs.
For details on comparisons, see Logical expressions. Also see Substrings.