开发者社区> 问答> 正文

druid的sql parser好像不支持oracle的within GROUP语法?报错

@wenshao 你好,想跟你请教个问题:

druid的sql parser好像不支持oracle的这种语法:

listagg(odoffer.offer_name,',') within GROUP(ORDER BY odoffer.offer_name)   
会报错:

1084556 WARN  2013-04-13 14:52:15881 com.alibaba.druid.sql.SQLUtils format error
com.alibaba.druid.sql.parser.ParserException: syntax error, expect BY, actual LPAREN group, pos 1221
    at com.alibaba.druid.sql.parser.SQLParser.accept(SQLParser.java:127)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser.parseGroupBy(OracleSelectParser.java:567)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser.query(OracleSelectParser.java:278)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser.select(OracleSelectParser.java:88)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser.parseTableSource(OracleSelectParser.java:711)
    at com.alibaba.druid.sql.parser.SQLSelectParser.parseFrom(SQLSelectParser.java:286)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser.query(OracleSelectParser.java:272)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleSelectParser.select(OracleSelectParser.java:88)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser.parseStatementList(OracleStatementParser.java:165)
    at com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser.parseStatementList(OracleStatementParser.java:138)
    at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:70)
    at com.alibaba.druid.sql.SQLUtils.toStatementList(SQLUtils.java:136)
    at com.alibaba.druid.sql.SQLUtils.format(SQLUtils.java:149)
    at com.alibaba.druid.filter.logging.LogFilter.logExecutableSql(LogFilter.java:514)
    at com.alibaba.druid.filter.logging.LogFilter.statementExecuteAfter(LogFilter.java:414)
    at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:442)
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2927)
    at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440)
    at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:2927)
    at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:94)
    at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:476)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:56)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:70)
    at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
    at $Proxy89.query(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:59)
    at $Proxy89.query(Unknown Source)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:57)
    at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:267)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:141)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:101)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:95)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:59)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
    at $Proxy24.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)


麻烦看一看这个问题,谢谢!

展开
收起
爱吃鱼的程序员 2020-06-22 20:22:29 2024 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    把完整的SQL发出来吧,我好做测试和支持listagg(odoffer.offer_name,',')withinGROUP(ORDERBYodoffer.offer_name)这个语法是ORACLE11gr2才支持的语法。或于此有关! select         
             ohoh.idid,
                  listagg(odoffer.offer_name,',')withingroup(orderbyodoffer.offer_name)offerNames
       FROM  ohohoh
            LEFTJOINood odofferONohoh.id=odoffer.order_id
          WHERE ohoh.create_time >=to_date(?,'yyyy-mm-ddhh24:mi:ss')
       groupby
              ohoh.id, 
              listagg(odoffer.offer_name,',')withingroup(orderbyodoffer.offer_name)offerNames

    2020-06-22 20:22:44
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
PostgresChina2018_樊文凯_ORACLE数据库和应用异构迁移最佳实践 立即下载
PostgresChina2018_王帅_从Oracle到PostgreSQL的数据迁移 立即下载
Oracle云上最佳实践 立即下载

相关镜像