String fpggSql = " select count(gg.regdept)||','||substr(gg.regdept, 1, 6) from GgWgxxb gg " + 
                        " where gg.regdate between to_date('"+ fpbegin +"', 'yyyy-mm-dd') and to_date('"+ fpend +"', 'yyyy-mm-dd') " + 
                        " and gg.ggly like '%" + ggly + "%'"   + 
                        " and gg.mtlxzl like '%"   + mt + "%'"   + 
                        " and gg.adno in (   " + 
                        "   select ad.comp_id.adno " + 
                        "   from AdCase ad         " + 
                        "   where ad.casedate between to_date('"+ labegin +"', 'yyyy-mm-dd') and to_date('"+ laend +"', 'yyyy-mm-dd') " + 
                        " ) " + 
                        " group by substr(gg.recdept, 1, 6) " + 
                        " having substr(gg.recdept, 1, 6) between 110101 and 110229 "; 下面错误提示。 
出错,原因:, expected in SELECT [ select count(gg.regdept)||','||substr(gg.regdept, 1, 6) from com.bpcc.egov.ggjg.po.GgWgxxb gg  where gg.regdate between to_date('2010-07-22', 'yyyy-mm-dd') and to_date('2010-07-23', 'yyyy-mm-dd')  and gg.ggly like '%%' and gg.mtlxzl like '%%' and gg.adno in (           select ad.comp_id.adno          from com.bpcc.egov.ggjg.po.AdCase ad               where ad.casedate between to_date('2010-07-22', 'yyyy-mm-dd') and to_date('2010-07-23', 'yyyy-mm-dd')  )          group by substr(gg.recdept, 1, 6)   having substr(gg.recdept, 1, 6) between 110101 and 110229 ] 

解决方案 »

  1.   

    把拼装的SQL打印出来 到数据库中执行调试看是否成功
      

  2.   

    很乱  LZ木有排版的 
    yyyy-MM-dd
      

  3.   


    原因:, expected in SELECT [.......]
      

  4.   

    substr(gg.recdept, 1, 6) having substr(gg.recdept, 1, 6
    不知道 lz 用的是 什么数据库substr  在数据里面 貌似不能执行吧
      

  5.   

    LZ为什么不用?去解决参数问题啊。请问楼主substr在hql里面支持么?
      

  6.   

    就是啊,hql面向对象的查询啊,一切都应是对象,在hql中有substr()命令么????
      

  7.   

    hsql和sql有很大差别,很多sql在hsql里是不支持的,比如in嵌套等等,你这个要改用jdbc了。