有谁知道如何解决我的问题,因为我认为语法很好,但编译器向我显示了这条消息错误。我不知道这是什么,因为从我的观点来看,一切都是正确的。这些是我的程序和我的包裹规格/身体
单机版程序编译正常
CREATE or REPLACE procedure pr_resultat
IS
CURSOR c_notes is
select avg(points) moy, num_eleve
from resultats
group by num_eleve;
result varchar(20) := '';
BEGIN
for elem in c_notes LOOP
if elem.moy < 10 then
result := 'failure';
elsif elem.moy >= 10 and elem.moy < 12 then
result := 'average';
elsif elem.moy >= 12 and elem.moy < 14 then
result := 'pretty good';
elsif elem.moy >= 14 and elem.moy < 16 then
result := 'good';
elsif elem.moy >= 16 then
result := 'very good';
end if;
DBMS_OUTPUT.PUT_LINE(elem.num_eleve || '->' || result);
end loop;
END;
/
包头编译正常
create or replace package package_prcd
is
procedure pr_resultat;
end package_prcd;
/
包体导致编译错误
PL-00103:遇到符号“C_NOTES”,但应为以下字符之一::=。(@%;在第6行
create or replace package body package_prcd
is
procedure pr_resultat
IS
begin
CURSOR c_notes is
select avg(points) moy, num_eleve
from resultats
group by num_eleve;
result varchar(20) := '';
for elem in c_notes LOOP
if elem.moy < 10 then
result := 'failure';
elsif elem.moy >= 10 and elem.moy < 12 then
result := 'average';
elsif elem.moy >= 12 and elem.moy < 14 then
result := 'pretty good';
elsif elem.moy >= 14 and elem.moy < 16 then
result := 'good';
elsif elem.moy >= 16 then
result := 'very good';
end if;
DBMS_OUTPUT.PUT_LINE(elem.num_eleve || '->' || result);
end loop;
end;
end package_prcd;
/
1条答案
按热度按时间daupos2t1#
在包体中,您错误地将过程的
BEGIN
移到了声明(游标和结果变量)之前。它必须在声明之后(在循环之前)。