ORA-00933: SQL 命令未正确结束(在简单插入语句中)

发布于 2024-09-08 09:57:58 字数 303 浏览 3 评论 0原文

以下简单的语句:

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

生成以下错误:

ORA-00933: SQL command not properly ended

我已经尝试过不使用分号以及使用分号,但都给出了错误。我确信变量也被绑定了。

我所有的 Google 搜索都显示这通常是由 ORDER BY 子句引起的,但显然我没有。 =P

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

那一片橙海, 2024-09-15 09:57:58

仅当使用 SELECT 填充 INSERT 语句 时,才定义 WHERE 子句。 IE:

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

否则,按原样指定值:

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

更新现有记录时指定 WHERE 子句

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

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
森林迷了鹿 2024-09-15 09:57:58

插入不能有 where 子句。也许您实际上是想更新

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

相对绾红妆 2024-09-15 09:57:58

where 子句在 insert 语句中相当不常见。也许您正在尝试更新?

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

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文