gpt4 book ai didi

java - "WITH"SQL 查询不工作java

转载 作者:行者123 更新时间:2023-12-02 12:28:03 25 4
gpt4 key购买 nike

我在下面的查询中使用“with data as”。当我在 sql Developer 中运行它时,它执行得很好,但是在 java 代码中,当我将查询作为普通字符串或通过 xml 配置文件中的 jdbc 模板调用时,它会给出错误的 SQL 语法。下面的查询有其他选择吗?

public class NppGWOrphanMessageDao extends DefaultDao {
String sql = "same sql as i posted"
private String replayGWOrphanMsgSQL;

public void setReplayGWOrphanMsgSQL(String replayGWOrphanMsgSQL) {
this.replayGWOrphanMsgSQL = replayGWOrphanMsgSQL;
}

public String getReplayGWOrphanMsgSQL() { return replayGWOrphanMsgSQL; }

public List<Map<String, Object>> getReplayList(HashMap<String, Object> epoch) {
return retrieveAll(replayGWOrphanListSQL, params);
return retrieveAll(sql, epoch); }
}
WITH DATA AS ( 
SELECT GLOB.ID, GLOB.CHARACTERS
FROM GW_LOB_STORE GLOB
WHERE
NOT EXISTS(SELECT 1 FROM GW_NPP_MSG_INTEGRITY M WHERE M.LOB_STORE_ID=GLOB.ID)
AND NOT EXISTS(SELECT 1 FROM GW_NPP_SAFE_STORE S WHERE S.LOB_STORE_ID=GLOB.ID)
AND NOT EXISTS(SELECT 1 FROM GW_POISON_LOG P WHERE P.LOB_STORE_ID=GLOB.ID)
AND GLOB.CREATED_TS > = :epoch)
SELECT
A.ID AS "GLOBID",
INQUEUEDTL.ID AS "INQUEID",
A.CHARACTERS AS "REQUESTBODY",
INQUEUEDTL.ENDPOINT_ID AS "ENDPOINTID",
INQUEUEDTL.HEADER AS "HEADERS"
FROM DATA A, GW_IN_QUEUE_DETAIL INQUEUEDTL
WHERE A.ID=INQUEUEDTL.ID;

最佳答案

为了完整起见:

此查询的问题在于其末尾的 ;

Oracle JDBC 驱动程序不能很好地处理它。

关于java - "WITH"SQL 查询不工作java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45407474/

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