我正在尝试创建一个新包,但是我得到了ORA-24344: success with compilation error
,我无法弄清楚问题是什么。
这是我的代码:
CREATE OR REPLACE PACKAGE BODY lucratori_pack AS
CURSOR disp_lucrator RETURN LucratorRecType IS
SELECT ID_LUCRATOR, NUME_LUCRATOR, PRENUME_LUCRATOR, SALARIUL FROM LUCRATORI ORDER BY SALARIUL;
PROCEDURE increase_sal(
emp_id LUCRATORI.ID_LUCRATOR%type,
emp_inc_sal LUCRATORI.SALARIUL%type
)
IS
emp_new_sal LUCRATORI.SALARIUL%type;
BEGIN
UPDATE LUCRATORI
SET SALARIUL = SALARIUL + emp_inc_sal
WHERE LUCRATORI.id_lucrator = emp_id
returning SALARIUL INTO emp_new_sal;
END increase_sal;
PROCEDURE getAllEmps
IS
CURSOR c is
SELECT NUME_LUCRATOR, PRENUME_LUCRATOR FROM LUCRATORI;
c_nume LUCRATORI.NUME_LUCRATOR%type;
c_prenume LUCRATORI.PRENUME_LUCRATOR%type;
BEGIN
open c;
loop
EXIT WHEN c%NOTFOUND;
fetch c INTO c_nume, c_prenume;
dbms_output.put_line('Numele: ' || c_nume || ' Prenumele: ' || c_prenume);
end loop;
close c;
END getAllEmps;
END lucratori_pack;
我已经测试了这些程序,但它们没有包含错误。下面是我在包中声明的2个过程中使用的表的代码:
CREATE TABLE Lucratori (
id_lucrator varchar2(5) constraint pk_lucrator primary key,
nume_lucrator varchar2(30),
prenume_lucrator varchar2(30),
data_nasterii date,
salariul number(5),
pozitia_ocupata varchar2(40),
id_companie varchar2(5),
constraint fk_lucrator_companie foreign key (id_companie)
references Companii(id_companie)
);
答案 0 :(得分:0)
首先,它是游标定义的错误位置,即PACKAGE BODY
定义之后的位置,可以定义一些全局参数。并且,该游标(disp_lucrator)无处使用。然后删除它:
CREATE OR REPLACE PACKAGE lucratori_pack AS
PROCEDURE increase_sal(emp_id LUCRATORI.ID_LUCRATOR%type,
emp_inc_sal LUCRATORI.SALARIUL%type);
PROCEDURE getAllEmps;
END lucratori_pack;
/
CREATE OR REPLACE PACKAGE BODY lucratori_pack AS
/* CURSOR disp_lucrator RETURN LucratorRecType IS
SELECT ID_LUCRATOR, NUME_LUCRATOR, PRENUME_LUCRATOR, SALARIUL FROM LUCRATORI ORDER BY SALARIUL;*/
PROCEDURE increase_sal(
emp_id LUCRATORI.ID_LUCRATOR%type,
emp_inc_sal LUCRATORI.SALARIUL%type
)
IS
emp_new_sal LUCRATORI.SALARIUL%type;
BEGIN
UPDATE LUCRATORI
SET SALARIUL = SALARIUL + emp_inc_sal
WHERE LUCRATORI.id_lucrator = emp_id
returning SALARIUL INTO emp_new_sal;
END increase_sal;
PROCEDURE getAllEmps
IS
CURSOR c is
SELECT NUME_LUCRATOR, PRENUME_LUCRATOR FROM LUCRATORI;
c_nume LUCRATORI.NUME_LUCRATOR%type;
c_prenume LUCRATORI.PRENUME_LUCRATOR%type;
BEGIN
open c;
loop
EXIT WHEN c%NOTFOUND;
fetch c INTO c_nume, c_prenume;
dbms_output.put_line('Numele: ' || c_nume || ' Prenumele: ' || c_prenume);
end loop;
close c;
END getAllEmps;
END lucratori_pack;
/