oracle PLS-00103:遇到符号“?” 当期待以下之一时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36203663/
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-19 03:11:50  来源:igfitidea点击:

PLS-00103: Encountered the symbol "?" when expecting one of the following

oracleplsqlcursor

提问by smackenzie

For some reason this wont work. I have got it down to the most basic operation to try and troubleshoot.

出于某种原因,这行不通。我已经把它归结为最基本的操作来尝试排除故障。

BEGIN
  FOR rec IN (
      select REGISTRATION_UID from DIM_REGISTRATION_SET
    )?
??  LOOP
      dbms_output.put_line('Testing 123');
  ??END LOOP;?
end;
/

My error is as below:

我的错误如下:

Error starting at line 1 in command:
BEGIN
  FOR rec IN (
      select REGISTRATION_UID from DIM_REGISTRATION_SET
    )?
??  LOOP
      dbms_output.put_line('Testing 123');
  ??END LOOP;?
end;
Error report:
ORA-06550: line 4, column 6:
PLS-00103: Encountered the symbol "?" when expecting one of the following:

   loop
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:

回答by Alex Poole

You seem to have an unexpected character in your code. If you copy and paste the rendered output from this question then it runs fine. If you copy the question source code (from the edit dialogue) then it gets that error.

您的代码中似乎有一个意想不到的字符。如果您复制并粘贴此问题的渲染输出,则它运行良好。如果您复制问题源代码(来自编辑对话框),则会出现该错误。

Dumping the code (again copied from the source, not the rendering) shows:

转储代码(再次从源代码复制,而不是渲染)显示:

select dump('(
          select REGISTRATION_UID from DIM_REGISTRATION_SET
        )?', 16)
from dual;?

DUMP('(SELECTREGISTRATION_UIDFROMDIM_REGISTRATION_SET)?',16)                   
--------------------------------------------------------------------------------
Typ=96 Len=73: 28,a,20,20,20,20,20,20,20,20,20,20,73,65,6c,65,63,74,20,52,45,47,
49,53,54,52,41,54,49,4f,4e,5f,55,49,44,20,66,72,6f,6d,20,44,49,4d,5f,52,45,47,49
,53,54,52,41,54,49,4f,4e,5f,53,45,54,a,20,20,20,20,20,20,20,20,29,c2,a0

So the space after the closing parenthesis isn't actually a space, it's Unicode character c2a0, which is a non-breaking space.

所以右括号后面的空格实际上不是空格,它是Unicode字符c2a0,这是一个不间断空格

The error message shows that too, if you dump that:

错误消息也显示了这一点,如果你转储:

select dump ('Encountered the symbol "?"', 16) from dual;

DUMP('ENCOUNTEREDTHESYMBOL"?"',16)                                             
--------------------------------------------------------------------------------
Typ=96 Len=27: 45,6e,63,6f,75,6e,74,65,72,65,64,20,74,68,65,20,73,79,6d,62,6f,6c
,20,22,c2,a0,22

I would guess you copied that code from somewhere (Word?) and it picked up that character, and it hasn't been translated to a normal space. Just replace it with a space, or remove it as it's redundant whitespace anyway.

我猜你从某个地方(Word?)复制了那个代码,它选择了那个字符,它没有被翻译成一个正常的空间。只需用空格替换它,或者将其删除,因为它无论如何都是多余的空格。

Actually, there are several others; two at the start of the LOOPline (followed by two normal spaces), and two immediately before END LOOP;(preceded by two normal spaces), and one after that statement; so those all need to be replaced too. (I'd be tempted to retype the whole thing, but that might not be practical for your full code).

实际上,还有其他几个;两个LOOP在行首(后跟两个普通空格),两个紧接在END LOOP;前面(前面有两个普通空格),一个在该语句之后;所以这些也都需要更换。(我很想重新输入整个内容,但这对于您的完整代码来说可能不切实际)。