PLS-00103:遇到符号"END".当期望+& =等 [英] PLS-00103: Encountered the symbol "END" when expecting + & = etc

查看:269
本文介绍了PLS-00103:遇到符号"END".当期望+& =等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

DECLARE 
v_grade CHAR(1) := UPPER('&grade');
appraisal VARCHAR(20);
BEGIN
appraisal := CASE v_grade
WHEN 'A' THEN 'Excellent'
WHEN 'B' THEN 'Very Good'
WHEN 'C' THEN 'Good'
WHEN 'No such grade'
END;
DBMS_OUTPUT.PUT_LINE('Grade: '||v_grade||'Appraisal '||appraisal);
END;
/

这是完整的错误代码:

ERROR at line 10:
ORA-06550: line 10, column 1:
PLS-00103: Encountered the symbol "END" when expecting one of the following:
 * & = - + < / > at in is mod remainer not rem then
 <an exponent (**)> <> or != or ~= >= <= <> and or like like2
 like4 between || multiset member submultiset.

我正在学习PL/SQL,正在尝试从书中举一个例子,但看来我做错了,请不要仅仅给出答案,我想知道您是如何解决此问题以及我是如何犯错的

I'm learning PL/SQL and I was trying an example from my book but it seems I did something wrong, please don't just give the answer I want to know how you troubleshooted this and how I did make the mistake.

推荐答案

您的最终子句应使用ELSE而不是WHEN:

Your final clause should use ELSE instead of WHEN:

DECLARE 
  v_grade CHAR(1) := 'C';
  appraisal VARCHAR(20);
BEGIN
  appraisal := 
    CASE v_grade
      WHEN 'A' THEN 'Excellent'
      WHEN 'B' THEN 'Very Good'
      WHEN 'C' THEN 'Good'
      ELSE  'No such grade'
    END;
  DBMS_OUTPUT.PUT_LINE('Grade: '||v_grade||', Appraisal '||appraisal);
END;

更新

向您提供有关如何解决此问题的建议并不容易(因为这在很大程度上取决于个人喜好);我通常尝试的事情是

Giving you advice on how to troubleshoot this isn't easy (since it's largely a matter of personal preference); things I usually try are

  • 缩小示例范围(在您的情况下,请删除CASE中的所有其他子句)
  • 从头开始重写查询中令人讨厌的部分
  • 复制一个有效的相似查询,并逐渐更改该查询以使其类似于有问题的查询,直到遇到错误为止
  • narrow down the example (in your case, get rid of all additional clauses in the CASE)
  • rewrite the offending part of the query from scratch
  • copy a similary query that works and change that query gradually to resemble the offending query until I encounter the error

这篇关于PLS-00103:遇到符号"END".当期望+&amp; =等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆