The LENGTH function
In the following query, the LENGTH function
calculates the number of bytes in the combined fname and lname columns
for each row where the length of company is greater than 15.
Figure 1. Query
SELECT customer_num,
LENGTH (fname) + LENGTH (lname) namelength
FROM customer
WHERE LENGTH (company) > 15;
Figure 2. Query result
customer_num namelength
101 11
105 13
107 11
112 14
115 11
118 10
119 10
120 10
122 12
124 11
125 10
126 12
127 10
128 11
Although the LENGTH function might not be useful when you work with DB-Access, it can be important to determine the string length for programs and reports. The LENGTH function returns the clipped length of a CHARACTER or VARCHAR string and the full number of bytes in a TEXT or BYTE string.
HCL Informix® also supports the CHAR_LENGTH function, which returns the number of logical characters in its string argument, rather than the number of bytes. This function is useful in locales where a single logical character might require more than a single byte of storage. For more information about the CHAR_LENGTH function, see the HCL Informix Guide to SQL: Syntax and the HCL Informix GLS User's Guide.