SQL PLS-00103:在简单更新块中遇到符号“文件结束”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3056410/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:34:35  来源:igfitidea点击:

PLS-00103: Encountered the symbol "end-of-file" in simple update block

sqloracleplsqlora-00933ora-06550

提问by rageingnonsense

The following Oracle statement:

以下 Oracle 语句:

 DECLARE ID NUMBER;
 BEGIN
  UPDATE myusername.terrainMap 
  SET playerID = :playerID,tileLayout = :tileLayout 
  WHERE ID = :ID
 END;

Gives me the following error:

给了我以下错误:

ORA-06550: line 6, column 15:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 3, column 19:
PL/SQL: SQL Statement ignored
ORA-06550: line 6, column 18:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

   ( begin case declare end exception exit for goto if loop mod
   null pragma raise return select update while with
   <an identifier> <a double-quoted>

I am pretty much at a loss. This appears to be a rather simple statement. If it helps any, I had a similar statement that performed an INSERT which used to work, but today has been giving me the same message.

我几乎不知所措。这似乎是一个相当简单的陈述。如果有帮助的话,我有一个类似的语句,它执行了一个曾经可以工作的 INSERT,但今天给了我同样的信息。

采纳答案by MJB

Add a semi-colon after where id=:id

后面加分号 where id=:id

回答by Jeffrey Kemp

You have a number of problems here:

你在这里有很多问题:

  1. Missing semi-colon (as MJB saw)

  2. :IDrefers to an in-bound variable, so your local declaration (DECLARE ID NUMBER;) is not being used.

  3. You're using a variable name which (apparently) is the same name as a colum in your table. If you try to use your local IDvariable, the query will still not use it unless you use a block label.

  1. 缺少分号(如 MJB 所见)

  2. :ID指的是一个入站变量,因此您的本地声明 ( DECLARE ID NUMBER;) 没有被使用。

  3. 您使用的变量名称(显然)与表中的列名称相同。如果您尝试使用您的局部ID变量,除非您使用块标签,否则查询仍然不会使用它。

That said, it looks like you're sending ID in as a bind variable anyway, so it's more likely that you should just remove the declaration from the block.

也就是说,看起来您无论如何都将 ID 作为绑定变量发送,因此您更有可能只从块中删除声明。

回答by Almanai

In addition to the previous you have to prevent spaces between equal operation ,:,and the value like this:

除了前面的,你必须防止相等操作之间的空格,:,和这样的值:

SQL> BEGIN  
2    IF x > y THEN high := x; END IF;  -- correct

3    IF x > y THEN high := x; ENDIF;   -- incorrect

4  END;

5  /

END;
ERROR at line 4:
ORA-06550: line 4, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
if

visit the website to read more.... https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/fundamentals.htm#LNPLS002

访问该网站以了解更多信息.... https://docs.oracle.com/cd/B28359_01/appdev.111/b28370/fundamentals.htm#LNPLS002