Syntax error in SQL statement “WITH” keyword throwing exception

为君一笑 提交于 2019-12-25 18:56:07

问题


I have also added another TMP2 and was not able to run the query... Could you please help me on this query? I am using Oracle 11g.

WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE) 
SELECT TMP1.REQUEST_NO FROM TMP1;

WITH TMP1(REQUEST_NO) AS
  (SELECT REQUEST_NO FROM QUOTE),
  TMP2(AGENT) AS (SELECT AGENT FROM AGENT_TAB)
SELECT TMP2.AGENT FROM TMP2;

The exception I got is :

org.h2.jdbc.JdbcSQLException:
Syntax error in SQL statement "WITH TMP1(REQUEST_NO) AS (SELECT REQUEST_NO FROM QUOTE),
[*]TMP2(AGENT) AS (SELECT AGENT FROM AGENT_TAB) SELECT TMP2.AGENT FROM TMP2 "; expected "(,
SELECT, FROM"; SQL statement:

The query is fine in sql developer but not working in the Junit tests. jdbc:h2:mem:request_no;MODE=Oracle We are using the h2 version 1.3.171 with windows 7 (64 bit) and jdk 1.7.0_25.


回答1:


Oracle supports the WITH clause, but it is looks like H2 does not support it: H2 SQL grammar

I would transform the query in the with part to the main query.



来源:https://stackoverflow.com/questions/22722561/syntax-error-in-sql-statement-with-keyword-throwing-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!