2013-03-12 116 views
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: 

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

回答

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

相关问题