1

以下程序在第 15 行产生一些语法错误。我不明白错误的原因。

declare
 value_1 INTEGER(5);
 value_2 INTEGER(5);
 value_3 INTEGER(5);
 value_4 INTEGER(5);
begin
 value_1 := 20;
 value_2 := 40;
 value_3 := 60;
 value_4 := 80;
 if value_1 > value_2
 then
  dbms_output.put_line('Value_1 > Value_2');
 end if;
 elsif value_4 > value_3 # statement 15
 then
  dbms_output.put_line('Value_4 > Value_3');
 end if;
 end;

抛出的错误:

Error report:
ORA-06550: line 15, column 9:
PLS-00103: Encountered the symbol "VALUE_4" when expecting one of the following:

:= . ( @ % ;
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
Error starting at line 1 in command:
declare
 value_1 INTEGER(5);
 value_2 INTEGER(5);
 value_3 INTEGER(5);
 value_4 INTEGER(5);
begin
 value_1 := 20;
 value_2 := 40;
 value_3 := 60;
 value_4 := 80;
if value_1 > value_2
then
  dbms_output.put_line('Value_1 > Value_2');
end if;
elsif value_4>value_3
then
  dbms_output.put_line('Value_4 > Value_3');
end if;
end;

Error report:
ORA-06550: line 15, column 9:
PLS-00103: Encountered the symbol "VALUE_4" when expecting one of the following:

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

这是什么错误?我该如何摆脱这个错误?

4

2 回答 2

1

我能看到你的陈述的唯一问题是额外的end if;

SQL 语句

declare
 value_1 INTEGER(5);
 value_2 INTEGER(5);
 value_3 INTEGER(5);
 value_4 INTEGER(5);
begin
 value_1 := 20;
 value_2 := 40;
 value_3 := 60;
 value_4 := 80;
 if (value_1 > value_2) then 
  dbms_output.put_line('Value_1 > Value_2');
 elsif (value_4 > value_3) then
  dbms_output.put_line('Value_4 > Value_3'); 
 end if;
end; 
于 2013-03-12T06:45:57.497 回答
0

它是工人......'mi对吗?

declare
 value_1 INTEGER(5);
 value_2 INTEGER(5);
 value_3 INTEGER(5);
 value_4 INTEGER(5);
begin
 value_1 := 20;
 value_2 := 40;
 value_3 := 60;
 value_4 := 80;
 if (value_1 > value_2)
 then
  dbms_output.put_line('Value_1 > Value_2');

 elsif (value_4 > value_3)
 then
  dbms_output.put_line('Value_4 > Value_3');
 end if;
 end;
 /

您已关闭 if 语句并再次打开 elsif 语句..我认为这是错误的。

于 2013-03-12T06:45:19.277 回答