为什么我在这个上遇到编译错误?

时间:2013-03-12 06:38:36

标签: oracle plsql oracle11g

以下程序在第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:

它有什么错误?我如何摆脱这个错误?

2 个答案:

答案 0 :(得分: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; 

答案 1 :(得分:0)

这是工人......我说得对吗?

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语句..我认为这是错误的。