ORA-00933: SQL command not properly ended (in simple insert statement)

The following simple statement:

INSERT INTO mydb.inventory (itemID) VALUES (:itemID) WHERE playerID = :ID;

Generates the following error:

ORA-00933: SQL command not properly ended

I have tried it without the semi-colon as well as with, but both give me the error. I am certain that the variables are being bound as well.

All my Google searches show that this is usually caused by an ORDER BY clause, but clearly I don't have one. =P

Answers


You only define a WHERE clause if you are populating the INSERT statement with a SELECT. IE:

INSERT INTO mydb.inventory 
  (itemID)
SELECT :itemID FROM DUAL

Otherwise, you specify the values as-is:

INSERT INTO mydb.inventory 
  (itemID)
VALUES
  (:itemID)

You specify a WHERE clause when you are updating an existing record:

UPDATE mydb.inventory 
   SET itemid = :itemid
 WHERE playerid = :ID

An insert can not have a where clause. Perhaps you actually meant to update?


A where clause is rather unusual in an insert statement. Perhaps you're trying to update instead?

UPDATE mydb.inventory SET itemID = :itemID WHERE playerID = :ID;

Need Your Help

Extend RecyclerView : Error Inflating Class com.example.MyRecyclerView

android android-5.0-lollipop android-custom-view android-recyclerview extend

I want to disable scroll of RecyclerView. For this I am trying to define a custom MyRecyclerView by extending RecyclerView.

npm install error with java

node.js node-gyp rebuild

While doing npm install , i am getting error related to node-gyp rebuild.