日期:2014-05-17  浏览次数:20732 次

select length(to_char(24,'00')) from dual 值怎么为3??
select length(to_char(24,'00')) from dual 值怎么为3??

应该是2把

------解决方案--------------------
Because the resulf of follwing sql is ' 24':
select to_char(24,'00') from dual;

You can use another method:
select lengthb(to_char(24)) from dual;
------解决方案--------------------
http://www.itpub.net/thread-404943-1-1.html 可以参考这个

然后看看这四个的结果
SQL code

select length(trim(to_char(24,'00'))) from dual 
select length(to_char(24,'00')) from dual 
select to_char(24,'00') from dual
select to_char(24,'fm00') from dual

------解决方案--------------------
探讨

Because the resulf of follwing sql is ' 24':
select to_char(24,'00') from dual;

You can use another method:
select lengthb(to_char(24)) from dual;

------解决方案--------------------
可以试着多举几个例子 看看各自的效果有什么不同 既然显示是3 肯定有道理咯
------解决方案--------------------
SQL code
select length(to_char(-24,'00')) from dual  --3
select to_char(-24,'00') from dual -- '-24'
--也是3,难道是隐藏符号位?

------解决方案--------------------
探讨
Because the resulf of follwing sql is ' 24':
select to_char(24,'00') from dual;

You can use another method:
select lengthb(to_char(24)) from dual;

------解决方案--------------------
-- 是的,前面有个空格(如果是负数,空格就变量成减号,主要是to_char()函数格式化的问题引起滴。
-- 例如:select to_char(-24,'00') from dual;则显示为:
-24

-- 估计这个空格是预留的符号位。