TEXT

 

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:

§      getLength() - returns an integer value indicating the size of a TEXT variable in bytes,

§      readFile() - reads data from the specified file and passes it to the memory or to the variable of a large data type indicated by the LOCATE statement,

§      writeFile() - writes data from the variable (source file or memory) to the specified file.

 

Restrictions applied to TEXT Variables

 

There are a number of restrictions which are applied to a value of the TEXT data type: