ORA-00933 SQL command not properly ended but good in SQL Developer

╄→гoц情女王★ 提交于 2021-02-02 08:59:30

问题


I am hoping someone can find what is the issue with my query because I am unable to see fault in it and Oracle SQL Developer seems to run the same query as the code in my Java Swing Application just fine.

My query in SQL Developer:

SELECT 
    ad.ID,ad.Script_Name,ad.Current_Status,
    ad.Issues_found_during_run,ad.Testers,
    ad.Run_Date,ad.Tools,u.fTag,u.role,
    dbms_lob.substr(u.avatar) 
FROM 
    allData ad 
INNER JOIN 
    users u 
ON 
    u.fTag = ad.lastUserWhoUpdated 
GROUP BY 
    ad.ID,ad.Script_Name,ad.Current_Status,
    ad.Issues_found_during_run,ad.Testers,
    ad.Run_Date,ad.Tools,u.fTag,u.role,
    dbms_lob.substr(u.avatar) 
ORDER BY 
    ad.ID ASC;

Which run perfectly and returns the needed records I would be expecting it to.

However, that same query in my Java Swing App does not seem to like it as it gives me the error of:

java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended.

My Java Swing App code:

connectToDB();

String query = 
      "SELECT " + 
        "ad.ID," + 
        "ad.Script_Name," + 
        "ad.Current_Status," + 
        "ad.Issues_found_during_run," + 
        "ad.Testers," + 
        "ad.Run_Date," + 
        "ad.Tools," + 
        "u.fTag," + 
        "u.role," + 
        "dbms_lob.substr(u.avatar) " + 
      "FROM " + 
        "allData ad " + 
      "INNER JOIN " + 
        "users u " + 
      "ON " + 
        "u.fTag = ad.lastUserWhoUpdated " +
      "GROUP BY " + 
        "ad.ID," + 
        "ad.Script_Name," + 
        "ad.Current_Status," + 
        "ad.Issues_found_during_run," + 
        "ad.Testers," + 
        "ad.Run_Date," + 
        "ad.Tools," + 
        "u.fTag," + 
        "u.role," + 
        "dbms_lob.substr(u.avatar) " + 
     "ORDER BY " + 
        "ad.ID;";

ResultSet rs = statement.executeQuery(query);            
ResultSetMetaData metaData = rs.getMetaData();
etc..etc..

My structure for those 2 tables is:

SCRIPT_NAME                  VARCHAR2(100 BYTE)
CURRENT_STATUS               VARCHAR2(50 BYTE)
ISSUES_FOUND_DURING_RUN      VARCHAR2(150 BYTE)
TESTERS                      VARCHAR2(30 BYTE)
RUN_DATE                     DATE
TOOLS                        VARCHAR2(20 BYTE)
T_SUITE                      NUMBER(38,0)
NOE2                         VARCHAR2(5 BYTE)
NOE3                         VARCHAR2(5 BYTE)
ID                           NUMBER(38,0)
LASTUSERWHOUPDATED           NUMBER
DATELASTMOD                  DATE

FTAG                         NUMBER(38,0)   
ROLE                         VARCHAR2(15 BYTE)
AVATAR                       CLOB

So, what could I be missing?


回答1:


Remove semicolon after the ad.ID like below. You don't need it

"ORDER BY " + 
    "ad.ID";


来源:https://stackoverflow.com/questions/54598208/ora-00933-sql-command-not-properly-ended-but-good-in-sql-developer

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