nan*_*din 4 sql oracle ora-01722
我有一个表有一个列的应用程序
BORROWINGTERM NUMBER(10,0) Nullable
Run Code Online (Sandbox Code Playgroud)
为什么这个脚本会抛出错误(ORA-01722无效的数字)
select nvl(borrowingterm, 'no term') from Application
Run Code Online (Sandbox Code Playgroud)
而这一个有效
select nvl(to_char(borrowingterm), 'no term') from Application
Run Code Online (Sandbox Code Playgroud)
这一个也有效
select nvl(1234,5678) from dual;
Run Code Online (Sandbox Code Playgroud)
基于这篇文章
NVL函数的第一个参数应该是字符串类型
保持简单,
例:
select nvl(to_char(borrowingterm), 'no term') from Application;
Run Code Online (Sandbox Code Playgroud)
//conert number to string and then provide string substitute value to column
select nvl(borrowingterm, 0') from Application;
Run Code Online (Sandbox Code Playgroud)
// replacing null with 0
简而言之,如果第一个参数是数字,那么Oracle会尝试将第二个参数转换为数字.
请参阅NVL文档
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions105.htm#i91798