zl程序教程

您现在的位置是:首页 >  其他

当前栏目

二则 ORA-01722: invalid number错误的处理,substr to_char之间的区别。连接符号错误 + ||

错误invalid连接 处理 区别 to number 之间
2023-09-11 14:15:13 时间
Select to_char(loginDate,'yyyy') as sYear, Count(1) as iCount From l_log where operation='登录'  
and InitFlag=1 Group By to_char(loginDate,'yyyy')
> ORA-01722: invalid number

sql语句改为:
Select substr(loginDate,1,4) as sYear, Count(1) as iCount From l_log where operation='登录'
  and InitFlag=1 Group By substr(loginDate,1,4) 

问题解决


还有一种是字符连接符号错误导致,oracle连接字符要用“||”不能用“+”

and ('','' + ListUser + '','' like %s and iStat <> -1)

改为

and ('','' || ListUser || '','' like %s and iStat <> -1)

问题解决