oracle – PLS-00103:遇到以下其中一项时遇到符号“;”:

前端之家收集整理的这篇文章主要介绍了oracle – PLS-00103:遇到以下其中一项时遇到符号“;”:前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的代码有什么问题
  1. sql> declare
  2. 2 mark number :=50;
  3. 3 begin
  4. 4 mark :=& mark;
  5. 5 if (mark between 85 and 100)
  6. 6 then
  7. 7 dbms_output.put_line('mark is A ');
  8. 8 else if (mark between 50 and 65) then
  9. 9 dbms_output.put_line('mark is D ');
  10. 10 else if (mark between 66 and 75) then
  11. 11 dbms_output.put_line('mark is C ');
  12. 12 else if (mark between 76 and 84) then
  13. 13 dbms_output.put_line('mark is B');
  14. 14 else
  15. 15 dbms_output.put_line('mark is F');
  16. 16 end if;
  17. 17 end;
  18. 18 /
  19. Enter value for mark: 65
  20. old 4: mark :=& mark;
  21. new 4: mark :=65;
  22. end;
  23. *

ERROR at line 17:
ORA-06550: line 17,column 4:
PLS-00103: Encountered the symbol “;” when expecting one of the following:
if

问题是else和if是两个运算符.由于你打开一个新的’if’,你需要一个相应的’end if’.

从而:

  1. declare
  2. mark number :=50;
  3. begin
  4. mark :=& mark;
  5. if (mark between 85 and 100) then
  6. dbms_output.put_line('mark is A ');
  7. else
  8. if (mark between 50 and 65) then
  9. dbms_output.put_line('mark is D ');
  10. else
  11. if (mark between 66 and 75) then
  12. dbms_output.put_line('mark is C ');
  13. else
  14. if (mark between 76 and 84) then
  15. dbms_output.put_line('mark is B');
  16. else
  17. dbms_output.put_line('mark is F');
  18. end if;
  19. end if;
  20. end if;
  21. end if;
  22. end;
  23. /

或者你可以使用elsif:

  1. declare
  2. mark number :=50;
  3. begin
  4. mark :=& mark;
  5. if (mark between 85 and 100)
  6. then
  7. dbms_output.put_line('mark is A ');
  8. elsif (mark between 50 and 65) then
  9. dbms_output.put_line('mark is D ');
  10. elsif (mark between 66 and 75) then
  11. dbms_output.put_line('mark is C ');
  12. elsif (mark between 76 and 84) then
  13. dbms_output.put_line('mark is B');
  14. else
  15. dbms_output.put_line('mark is F');
  16. end if;
  17. end;
  18. /

猜你在找的Oracle相关文章