gpt4 book ai didi

java - ORA-00905 : missing keyword error on query that runs fine in SQL Developer

转载 作者:行者123 更新时间:2023-11-30 01:59:22 29 4
gpt4 key购买 nike

我正在尝试使用 JOIN 函数从架构中的几个不同表访问信息。在我在 TABLE3 上添加 FULL OUTER JOIN 之前,代码工作正常。我对 Oracle 还很陌生,所以尽管我一直在阅读它,但到目前为止我还无法指出我的错误。

这里值得注意的一点是,这个相同的查询在 Oracle SQL Developer 上完美运行,但当我在 Java (Netbeans IDE) 中与其余代码一起运行它时,会抛出缺少关键字错误。两者是否有不同的语法要求?

这是我的代码:

SELECT 
t2.A1 as temp1,
t2.A2 as temp2,
t2.A3 as temp3,
t2.A4 as temp4,
t2.A5 as temp5,
t2.A6 as temp6,
t2.A7 as temp7,
t2.A8 as temp8,
t3.A9 as temp9,
t2.A10 as temp10,
t2.A11 as temp11,
t2.A12 as temp12,
t2.A13 as temp13,
t2.A14 as temp14,
t2.A15 as temp15,
t2.A16 as temp16,
t2.A17 as temp17,
t2.A18 as temp18,
t2.A19 as temp19,
t2.A20 as temp20,
t2.A9 as temp21,
t2.A21 as temp22,
t2.A22 as temp23,
t1.deets as deets
FROM SCHEMA1.TABLE2 t2
FULL OUTER JOIN
SCHEMA1.TABLE3 t3
ON t2.A1 = t3.A23
LEFT OUTER JOIN
(select A24, LISTAGG(A25, ',') WITHIN GROUP (ORDER BY A26) as deets
FROM SCHEMA1.NA av
WHERE (A26 = 'TYPE1' OR A26 = 'TYPE2')
Group by A24) t1
ON t1.A24 = t2.A1
WHERE
(t2.A2 between (TO_CHAR (SYSDATE, 'YYYYMMDD') || '000000')
AND (TO_CHAR (SYSDATE+15, 'YYYYMMDD') || '000000')
OR t2.A11 between (TO_CHAR (SYSDATE, 'YYYYMMDD') || '000000')
AND (TO_CHAR (SYSDATE+15, 'YYYYMMDD') || '000000'))
AND TRIM(t2.A27) IS NOT NULL
AND t2.A28 = 'SOMESPEC'
AND t2.A3 = 'SOMEOTHERSPEC'
order by temp2 desc;

这是我收到的错误:

[DEBUG: 2018-11-20 08:58:24.426] [query]
java.sql.SQLException: ORA-00905: missing keyword

如有任何建议,我们将不胜感激

编辑:这也是 Java 中的查询:

String query = "SELECT "
+ "t2.A1 as temp1, "
+ "t2.A2 as temp2, "
+ "t2.A3 as temp3, "
+ "t2.A4 as temp4, "
+ "t2.A5 as temp5, "
+ "t2.A6 as temp6, "
+ "t2.A7 as temp7, "
+ "t2.A8 as temp8, "
+ "t3.A9 as temp9, "
+ "t2.A10 as temp10, "
+ "t2.A11 as temp11, "
+ "t2.A12 as temp12, "
+ "t2.A13 as temp13, "
+ "t2.A14 as temp14, "
+ "t2.A15 as temp15, "
+ "t2.A16 as temp16, "
+ "t2.A17 as temp17, "
+ "t2.A18 as temp18, "
+ "t2.A19 as temp19, "
+ "t2.A20 as temp20, "
+ "t2.A9 as temp21, "
+ "t2.A21 as temp22, "
+ "t2.A22 as temp23, "
+ "t1.deets as deets "
+ "FROM SCHEMA1.TABLE2 t2 "
+ "FULL OUTER JOIN "
+ "SCHEMA1.TABLE3 t3"
+ "ON t2.A1 = t3.A23"
+ "LEFT OUTER JOIN "
+ "(select A24, LISTAGG(A25, ',') WITHIN GROUP (ORDER BY A26) as deets "
+ "FROM SCHEMA1.NA av "
+ "WHERE (A26 = 'TYPE1' OR A26 = 'TYPE2') "
+ "Group by A24) t1 "
+"ON t1.A24 = t2.A1 "
+ "WHERE "
+ "(t2.A2 between (TO_CHAR (SYSDATE, 'YYYYMMDD') || '000000') "
+ "AND (TO_CHAR (SYSDATE+15, 'YYYYMMDD') || '000000') "
+ "OR t2.A11 between (TO_CHAR (SYSDATE, 'YYYYMMDD') || '000000') "
+ "AND (TO_CHAR (SYSDATE+15, 'YYYYMMDD') || '000000')) "
+"AND "
+ "TRIM(t2.A27) IS NOT NULL "
+ "AND t2.A28 = 'SOMESPEC' "
+ "AND t2.A3 = 'SOMEOTHERSPEC'"
+ "order by temp2 desc";

最佳答案

在行中添加尾随空白

+ "SCHEMA1.TABLE3 t3"
+ "ON t2.A1 = t3.A23"

关于java - ORA-00905 : missing keyword error on query that runs fine in SQL Developer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53395910/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com