在开发中遇到一个奇怪的问题,写了一条SQL语句,在PLSQL中可以运行,可是加到程序中却运行不了.
SQL如下:
select t.frq frq,sum(nvl(t.ghrs,0)) ghrs,sum(nvl(t.mzrc,0)) mzrc,max(nvl(t.zdcf,0)) zdcf, sum(nvl(t.cfsl,0)) cfsl,sum(nvl(t.czrs,0)) czrs,sum(nvl(t.mzcfyss,0)) mzcfyss, min(nvl(t.zxcf,0)) zxcf,sum(nvl(t.cfze,0)) cfze,sum(nvl(t.fzrs,0)) fzrs, case when sum(nvl(t.mzcfyss,0)) = 0 then 0 else round(sum(nvl(t.mzrc,0)) / sum(nvl(t.mzcfyss,0)),4) end yspjmzrs, case when sum(nvl(t.mzcfyss,0)) = 0 then 1 else round(sum(nvl(t.cfsl,0)) / sum(nvl(t.mzcfyss,0)),4) end yspjcfsl, case when sum(nvl(t.mzcfyss,0)) = 0 then 0 else round(sum(nvl(t.cfze,0)) / sum(nvl(t.mzcfyss,0)),4) end yspjcfze, sum(nvl(t.yyrs,0)) yyrs,sum(nvl(t.ryrs,0)) ryrs,sum(nvl(t.cyrs,0)) cyrs, sum(nvl(t.cysmrs,0)) cysmrs,sum(nvl(t.zyrs,0)) zyrs,sum(nvl(t.kfcws,0)) kfcws, case when sum(nvl(t.kfcws,0)) = 0 then 0 else round(sum(nvl(t.zycws,0)) / sum(nvl(t.kfcws,0)),4) end cwsyl, case when sum(nvl(t.cyrs,0)) = 0 then 0 else round(sum(nvl(t.zzyr,0)) / sum(nvl(t.cyrs,0)),4) end pjzyr, sum(nvl(t.wzbrs,0)) wzbrs,sum(nvl(t.hjsr,0)) hjsr,sum(nvl(t.ylsr,0)) ylsr, sum(nvl(t.ypsr,0)) ypsr,sum(nvl(t.qtsr,0)) qtsr from zhcx.yzrbzhxx t where t.frq >= to_date('2010-07-14','yyyy-mm-dd') and t.frq <= to_date('2011-07-14','yyyy-mm-dd') group by t.frq order by t.frq ;
?
测试报以下错误:
org.springframework.jdbc.BadSqlGrammarException: StatementCallback;
Caused by: java.sql.SQLException: ORA-00911: 无效字符
?
?
解决方案:
是这条SQL的结束处加了一个 ";" 封号引起的异常...删除";",测试通过.
?
-------------------工作积累 尹当