DB2 SQL Error: SQLCODE=-418, SQLSTATE=42610, SQLERRMC=null, DRIVER=4.9.78


查询的语句为:
select t.rq,t.pm,coalesce(m.sje,0) sje,coalesce(m.fje,0) fje from ( select b.rq,c.pm from  (values(?),(?),(?),(?),(?) ) b(rq), (values('00010002'),('00020002')) c(pm) ) t left join (select substr(a.LMZJBXX_RQ,1,7) rq,a.LMZJBXX_PM pm,sum(a.LMZJBXX_SJE) sje,sum(a.LMZJBXX_FJE) fje from JCJYXT_HSZM_LMZJBXX a where exists(select 1 from ucap_dept where UNIT_CODE like ? and DEPT_UNID=a.LMZJBXX_JZDW)  group by substr(a.LMZJBXX_RQ,1,7),a.LMZJBXX_PM ) m on t.rq=m.rq and t.pm=m.pm  order by t.rq,t.pm


Friends say:
the Parameter markers CAN Never BE Used:


    * in A of Statement that IS not A the Prepared of Statement
    * in at The fullselect of A the CREATE VIEW of Statement
    * in at The triggered Action of A the CREATE TRIGGER of Statement
    * in A Query Captured by the DB2 Query Patroller 


at The Not Processed CAN bE Statement.


the User the Response:. Correct the Statement the syntax of the If Not untyped Parameter markers are allowed, use the CAST Specification the marker a to give the Parameter Data type. 


this is the error in the DB2 pick out.
I think the result is set in the "?" Out of the question.



Therefore, the query modification:
the SELECT t.rq, t.pm, COALESCE (m.sje, 0) SJE, COALESCE (m.fje, 0) fje 
from (the SELECT b.rq, c.pm from ( values ( ' 2014-09 '), (' 2014-08 '), (' 2014-07 '), (' 2014-06 '), (' 2014-05 ') ) B (RQ), (values (' 00,010,002 ') , ( '00020002')) c (pm)) t left join (select substr (a.LMZJBXX_RQ, 1,7) rq, a.LMZJBXX_PM pm, sum (a.LMZJBXX_SJE) sje, sum (a.LMZJBXX_FJE) fje from JCJYXT_HSZM_LMZJBXX a where exists (select 1 from ucap_dept where UNIT_CODE like? and DEPT_UNID = a.LMZJBXX_JZDW) group by substr (a.LMZJBXX_RQ, 1,7), a.LMZJBXX_PM) m on t.rq = m.rq and t.pm = m.pm order by t.rq, t.pm
re-run through.
Conclusion: The result set can not pass parameters.

Reproduced in: https: //my.oschina.net/u/2552902/blog/543869

Guess you like

Origin blog.csdn.net/weixin_34162629/article/details/92327016