SQL PLS-00103:在预期以下情况之一时遇到该符号:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20574967/
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
PLS-00103: Encountered the symbol when expecting one of the following:
提问by sunleo
It seems ok but am getting exception please correct me.
看起来没问题,但出现异常,请纠正我。
declare
var_number number;
begin
var_number := 10;
if var_number > 100 then
dbms_output.put_line(var_number||' is greater than 100');
elseif var_number < 100 then
dbms_output.put_line(var_number||' is less than 100');
else
dbms_output.put_line(var_number||' is equal to 100');
end if;
end;
Exception :
例外 :
ORA-06550: line 8, column 8:
PLS-00103: Encountered the symbol "VAR_NUMBER" when expecting one of the following:
:= . ( @ % ;
ORA-06550: line 13, column 4:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
if
回答by OldProgrammer
The keyword for Oracle PL/SQL is "ELSIF" ( no extra "E"), not ELSEIF (yes, confusing and stupid)
Oracle PL/SQL 的关键字是“ELSIF”(没有额外的“E”),而不是 ELSEIF(是的,令人困惑和愚蠢)
declare
var_number number;
begin
var_number := 10;
if var_number > 100 then
dbms_output.put_line(var_number||' is greater than 100');
elsif var_number < 100 then
dbms_output.put_line(var_number||' is less than 100');
else
dbms_output.put_line(var_number||' is equal to 100');
end if;
end;
回答by Dulith De Costa
The IF statement has these forms in PL/SQL
:
IF 语句具有以下形式PL/SQL
:
IF THEN
IF THEN ELSE
IF THEN ELSIF
You have used elseif
which in terms of PL/SQL is wrong. That need to be replaced with ELSIF
.
你用过elseif
which 就 PL/SQL 而言是错误的。那需要替换为ELSIF
.
So your code should appear like this.
所以你的代码应该是这样的。
declare
var_number number;
begin
var_number := 10;
if var_number > 100 then
dbms_output.put_line(var_number ||' is greater than 100');
--elseif should be replaced with elsif
elsif var_number < 100 then
dbms_output.put_line(var_number ||' is less than 100');
else
dbms_output.put_line(var_number ||' is equal to 100');
end if;
end;
回答by user4497532
begin
var_number := 10;
if var_number > 100 then
dbms_output.put_line(var_number||' is greater than 100');
else if var_number < 100 then
dbms_output.put_line(var_number||' is less than 100');
else
dbms_output.put_line(var_number||' is equal to 100');
end if;
end if;