数据库报“ORA-01722: 无效数字”错误的解决办法
程序员文章站
2022-03-23 19:30:06
报错信息:ora-01722: 无效数字
问题sql:
select a.*,
b.fund_code as fund_code,
b.fund_fullname as fund_fu...
报错信息:ora-01722: 无效数字
问题sql:
select a.*, b.fund_code as fund_code, b.fund_fullname as fund_fullname from bsp_sys_attach a,bsp_fund_base b where a.entity_id=b.fund_id /* 此处a.entity_id的类型为varchar; b.fund_id的类型为number; 两者类型不匹配所以报错。 */
更改后正确sql:
select a.*, b.fund_code as fund_code, b.fund_fullname as fund_fullname from bsp_sys_attach a,bsp_fund_base b where a.entity_id=to_char(b.fund_id) /* 类型转换函数to_char() */
拓展:
将日期型转换为字符串to_char()
select to_char (sysdate, 'yyyy-mm-dd hh24:mi:ss am') from dual
将数字型转换为字符串to_char()
select to_char(123.45678,'$99999.999') from dual;
将字符换转换为日期to_date()
select to_date ('20100913', 'yyyy-mm-dd') from dual;
将字符串转换为数字to_number()
select to_number('01') from dual;
下一篇: 三大运营商都在为车联网业务积极布局