Character strings can be stored using TEXT data type. The TEXT data type is similar to the BYTE data type, but whereas BYTE data type can store any information that can be stored in digital form, the TEXT data type can store strings of ASCII printable characters. It can also include the following whitespace characters:
Some locales support other whitespace characters. However these characters are not included to the characters supported by default, so if any other non-printable character that is not listed above is included into the TEXT value, unexpected result may occur and the TEXT value may be processed improperly.
TEXT values have a theoretical size limit of 231 bytes, although the practical limit is determined by the available system storage. In East Asian locales, more than one byte of storage space may be required per character.
A TEXT variable is usually used to manipulate a database column of TEXT type or to display a text file using a text editor. After a variable of TEXT data type has been declared, the LOCATE statement should be used to inform the program about the location of the information stored in this variable.
A value retrieved from a column of TEXT type is completely or partially assigned to a variable of TEXT data type. To assign only a part of the whole TEXT value, use square brackets, e.g.:
SELECT treaty_text [1,245] INTO treaty FROM doc_tab
The above example results in retrieving the first 245 bytes from the text of the treaty and saving them to the variable treaty. In most locales one byte is used to store one character, there are some whitespace symbols that require more space but in general this will result in retrieving the first 245 symbols from the text.
You can use these methods to manipulate variables of TEXT data type:
There are a number of restrictions which are applied to a value of the TEXT data type:
A form-only field of the TEXT data type or a field that represents a database column of TEXT data type can display only small amount of text, the limit is set by the length of such field or by the declared size of a column. To view and edit the complete text, you must assign PROGRAM attribute to such field.
WORDWRAP attribute can be used to display the whole text or part of it depending on the total length of all the segments, although the text cannot be edited in such a way.
Only three attributes can be used with a form field of the TEXT type, these are: PROGRAM, WORDWRAP and COLOR.
TEXT values are passed by reference in CALL, RETURN and OUTPUT TO REPORT statements. The DISPLAY TO and DISPLAY (console) statement can be used to display the TEXT value, whereas DISPLAY AT statement can also be used, but will display only one line of text, the rest will be truncated.
You can assign the following values to a TEXT variable: NULL or values of CHAR, TEXT, VARCHAR, STRING data types.