ORA-00933: SQL command not properly ended | ORA-00933 Resolution

ORA-00933 : SQL command not properly ended :

In my previous articles, I have given the proper idea of different oracle errors, which are frequently come. In this article, I will try to explain the most common error, which has been shared, on google 10 k times per month. ORA-00933 is straightforward error might come because of inappropriate use of any SQL clause.

Error Cause and Resolution :

ORA-00933 error is very common error, which will come because of using the SQL clause in inappropriate syntax. There is no another root cause of this error. User might check the clause at appropriate place to resolve this issue. I will explain different scenarios of this error

  1. Use of Order by / Group by Clause in Insert Statement :

This error will come because of the improper use of ‘Order by’ clause in insert statement. Kindly try to implement following scenario :

CREATE TABLE Test_Error

(Roll_no NUMBER(10),NAME VARCHAR2(30));

 

INSERT INTO Test_Error

values(1,’Amit’) order by roll_no;

 

ORA-00933

 

Resolution of error :

Kindly remove the order by clause from select statement.

 

INSERT INTO Test_Error

VALUES(1,’Amit’);

commit;

 

User needs to check the error the syntax of inappropriate clauses in SQL.The clauses might be either ‘Order by’ or ‘Group by’.So the root cause of this error is placing of clause at inappropriate place.

  1. Use of Order by / Group by Clause in delete Statement :

In above example I have given example of order by clause. In this example I will try to produce this error with group by clause. User can not be used the group by clause with delete statement. This is most common syntax error.

delete from Test_Error group by Roll_no;

 

Error report:

SQL Error: ORA-00933: SQL command not properly ended

  1. 00000 – “SQL command not properly ended”

*Cause:

*Action:

 

Solution of the error :

Remove group by Roll_no clause. The statement will be:

Delete from Test_Error;

 

3.Improper use of joins in update statement :

The improper use of join in update statement one of the main cause of this error.

Example :

UPDATE S_SRV_REQ set SR_NUM =’1000’

FROM S_SRV_REQ_XM SRVX

JOIN S_SRV_REQ sr ON SRVX.ROW_ID = sr.PAR_ROW_ID;

 

In above example user is trying to update the SR_NUM but  user is using the join condition between two tables. So user needs to change the query as below :

UPDATE S_SRV_REQ SR

SET SR_NUM =’1000’

WHERE SR.ROW_ID IN (SELECT SRVX.PAR_ROW_ID FROM S_SRV_REQ_XM SRVX);