PLS-00103:在期望以下之一时遇到符号 "END":。 ;符号“;”被替换为 "END" 以继续
PLS-00103: Encountered the symbol "END" when expecting one of the following: . ; The symbol ";" was substituted for "END" to continue
我写了下面的程序:
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;
/
我写了下面的程序:
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;
/