SQL LENGTH scalar function in DB2 for i SQL |
LENGTH
The LENGTH function returns the length of a value.
Syntax
LENGTH(expression)
The expression is a value of any built-in data type other than XML. The result can be null if the argument is null.
The length of all other values is the number of bytes used to represent the value:
Example
SELECT length(current_date), length(current_time), length(current_timestamp), length(cast('TEST' as char(10))), length(cast('TEST' as varchar(10))), length(1), length(554654545456), length(50551.5) FROM sysibm.SYSDUMMY1
Output:
LENGTH LENGTH LENGTH LENGTH LENGTH LENGTH ( 1 ) LENGTH LENGTH ( 50551.5 ) 4 3 10 10 4 4 8 4