当前位置: 代码迷 >> DB2 >> oracle 的 length函数与db2的length函数解决思路
  详细解决方案

oracle 的 length函数与db2的length函数解决思路

热度:4629   发布时间:2013-02-26 00:00:00.0
oracle 的 length函数与db2的length函数
在oracle 中 select length('李琳') from dual 返回2
在db2 中select length('李琳') from sysibm.SYSDUMMY1 返回4
db2 有没有返回字符个数的length函数,像oracle一样?

------解决方案--------------------------------------------------------
Db2 9 已经有个这个函数

LENGTH ( expression, CODEUNITS16/ CODEUNITS32/ OCTETS ) 


CODEUNITS16, CODEUNITS32, or OCTETS Specifies the string unit of the result. CODEUNITS16 specifies that the result is to be expressed in 16-bit UTF-16 code units. CODEUNITS32 specifies that the result is to be expressed in 32-bit UTF-32 code units. OCTETS specifies that the result is to be expressed in bytes. If a string unit is explicitly specified, and if expression is not string data, an error is returned (SQLSTATE 428GC). If a string unit is specified as CODEUNITS16 or CODEUNITS32, and expression is a binary string or bit data, an error is returned (SQLSTATE 428GC). If a string unit is specified as OCTETS and expression is a binary string, an error is returned (SQLSTATE 42815). For more information about CODEUNITS16, CODEUNITS32, and OCTETS, see “String units in built-in functions” in “Character strings”.
  相关解决方案