0
我正在使用「with data as」,如下面的查詢。當我在sql開發者中運行它時,它執行的很好,但是當我以普通字符串或通過xml配置文件中的jdbc模板調用查詢時,它在java代碼中,它給了我糟糕的SQL語法。下面的查詢有其他選擇嗎?「WITH」SQL查詢不起作用java
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;
什麼是錯誤? – user7294900
它給了我ORA - 00911無效字符\ n – user3436400
我認爲:應該用時代替代? – user7294900