【问题标题】:PLS--00103 error in pl/sqlPLS--00103 pl/sql 中的错误
【发布时间】:2013-05-13 13:18:55
【问题描述】:

我正在编写一个简单的老年人检查程序。但这个错误让我感到困惑。代码如下

declare
  gen char(1);
    age number(3);

begin
  gen:='&gen';
    age:=&age;

  if age>65 and gen='m'
    then
      dbms_output.put_line("senior citizen");

  elsif age>60 and gen='f'
    then
      dbms_output.put_line("senior citizen");

  else
      dbms_output.put_line(" not a senior citizen");
  endif;
end;

error at line 20:
ora 06550:line 20, column 4
pls-00103:encountered symbol ';' when expecting one of the following if

我真的不知道怎么了

【问题讨论】:

    标签: plsql pls-00103


    【解决方案1】:
    declare
      gen char(1);
        age number(3);
    
    begin
      gen:='&gen';
        age:=&age;
    
      if age>65 and gen='m'
        then
          dbms_output.put_line('senior citizen');
    
      elsif age>60 and gen='f'
        then
          dbms_output.put_line('senior citizen');
    
      else
          dbms_output.put_line(' not a senior citizen');
      end if;
    end;
    

    使用dbms_output.put_line时,您必须使用'代替"来显示字符串消息
    还有一个endif,必须替换为end if
    希望对朋友有所帮助。

    【讨论】:

    【解决方案2】:

    应该是“end if;”,而不是“endif;”。

    (是的,这与“elsif”有些不一致。有趣的老东西,语法... :-)

    分享和享受。

    【讨论】:

      【解决方案3】:
      declare
          gen char(1)   := lower(:Gender)   ;
          age number(3) := :Age;
      begin
      
        if ( 
          (age>65 and gen = 'm') OR (age>60 and gen ='f')
        )then
          dbms_output.put_line('senior citizen');
        else
          dbms_output.put_line(' not a senior citizen');
      end if;
      end;
      

      【讨论】:

      • 如果您确切地告诉您在代码中进行了哪些更改以使其正常工作,这将很有帮助。对于功能访问者来说,他们必须将原始代码与您的代码进行比较以猜测他们应该如何处理他们的代码来解决类似问题。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-22
      • 2011-11-26
      • 1970-01-01
      相关资源
      最近更新 更多