gpt4 book ai didi

plsql - PLS-00103 : Encountered the symbol “END” when expecting one of the following: . ; The symbol “;” was substituted for “END” to continue

转载 作者:行者123 更新时间:2023-12-02 10:56:27 25 4
gpt4 key购买 nike

我编写了以下程序:

create or replace procedure ADDPHONE(IDPELATH  in number,IDTHLEFWNO in number )
is
cursor cursor_number is select id_pelath ,TelephoneNumber from PhoneNumbers
where id_pelath>2;
more_than_two_numbers exception;
begin
open cursor_number ;
fetch cursor_number into IDPELATH;
if id_pelath%FOUND then raise more_than_two_numbers
end if;
close cursor_number;
exception
when more_than_two_numbers then
raise_application_error('Error');
END;
/

运行它时,出现以下错误:
PLS-00103: Encountered the symbol "END" when expecting one of the following:     . ; 
The symbol ";" was substituted for "END" to continue.

您能帮我发现错误吗?

最佳答案

该过程中存在多个问题。

  • 输入参数从未在主体中使用。
  • 游标声明为获取两个,但是FETCH语句仅获取一个。
  • 错误使用raise_application_error,它需要两个输入参数。

  • 我已经修改了应该执行的代码,
     CREATE or REPLACE procedure ADDPHONE(IDPELATH  in number,IDTHLEFWNO in number)
    is

    lv_cnt number(10):=0;
    more_than_two_numbers exception;

    BEGIN

    select COUNT(1) INTO lv_cnt
    from PhoneNumbers
    where id_pelath = IDPELATH
    and TelephoneNumber = IDTHLEFWNO;

    if (lv_cnt > 2) then
    raise_application_error(-20001,'Error - More than two Numbers ');
    end if;

    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20002,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END ADDPHONE;


    /

    关于plsql - PLS-00103 : Encountered the symbol “END” when expecting one of the following: . ; The symbol “;” was substituted for “END” to continue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62430223/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com