The LENGTH() function

Informix® provides the LENGTH() function:

SELECT LENGTH("aaa"), LENGTH(col1) FROM table

IBM® DB2® has a equivalent function with the same name, but there is some difference:

Solution

You must check if the trailing blanks are significant when using the LENGTH()function.

If you want to count the number of characters by ignoring the trailing blanks, you must use the RTRIM() function:

SELECT LENGTH(RTRIM(col1)) FROM table