@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)
麻烦看一看这个问题,谢谢!
把完整的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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。