STRING

 

STRING data type provides a variant holder for the character strings. It does not require the size to be declared; the size of a STRING variable changes depending of the size of the value stored in it.

 

STRING variables cannot be used in the SQL expressions for receiving the values of a query, since the size of the receiving variables needs to be set before the values are returned.

 

 

 

The STRING values can be compared with a CHAR, VARCHAR or STRING value. No blank spaces are added to or stripped of a variable of the STRING data type.  Unlike VARCHAR variables, STRING variables can contain an empty string without being NULL. Thus, if you used the trim() built-in function or the CLIPPED operator against a STRING variable containing only whitespaces, the variable will contain an empty string which will not be NULL. The IS NULL operator used with such a string will return FALSE.  A VARCHAR variable in this case will be evaluated to NULL. However, STRING variables are still initialized to NULL when they are declared.

Like VARCHAR variables, STRING variables store significant trailing whitespaces added to the value explicitly and does not add whitespaces at the end of values automatically like the CHAR variables do. Thus strings "abcd   " and "abcd" stored in STRING variables will be different when compared.

 

The size of such variable can be increased or decreased dynamically during runtime, depending on the length of the value assigned to it. When no value is assigned to a STRING variable, it has the length of a single character.

 

Usually the STRING data type requires 1 byte per character, so the size in bytes is equal to the size in characters, but in some East Asian locales, a character may require more than one byte to be stored. Some white space characters can also occupy more than one byte.

 

STRING variables can be manipulated by these methods:

append()

equals()

equalsIgnoreCase()

getCharAt()

getIndexOf()

getLength()

subString()

toLowerCase()

toUpperCase()

trim()

trimLeft()

trimRight()

 

util.Strings class provides a set of methods that can be used with variables of STRING data type:

util.Strings.base64Decode()

util.Strings.base64Encode()

util.Strings.base64DecodeToString()

util.Strings.base64EncodeFromString()

util.Strings.urlDecode()

util.Strings.urlEncode()