这个查询来自quest central安装脚本,我截取了其中出错的部分,如下:
下面查询,运行时报:ORA-01722: invalid number错误
select DISTINCT UPPER(t.instance),s.machine
from v$parameter p, v$thread t , v$session s
where t.thread# = DECODE(TO_NUMBER(p.value),0,1,TO_NUMBER(p.value))
and p.name='thread';
第 3 行出现错误:
ORA-01722: invalid number
注释掉v$session 之后,不再报错
select DISTINCT UPPER(t.instance) -- , s.machine
from v$parameter p,v$thread t -- , v$session s
where t.thread# = DECODE(TO_NUMBER(p.value),0,1,TO_NUMBER(p.value))
and p.name='thread';
保留v$session 注释掉v$parameter 和v$thread 的连接,也不再报错
select DISTINCT UPPER(t.instance),s.machine
from v$parameter p,v$thread t , v$session s
where -- t.thread# = DECODE(TO_NUMBER(p.value),0,1,TO_NUMBER(p.value)) and
p.name='thread';
可见问题是两次注释部分相冲突,但是我不明白这两者为什么会冲突,请高手指点!
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/310745/viewspace-6323/,如需转载,请注明出处,否则将追究法律责任。