我正在做学校作业,我的代码有错误。我创建了一个 PLSQL 包:
create or replace
PACKAGE GestionProjets AS
TYPE Signaletique IS TABLE OF EMPLOYES%ROWTYPE INDEX BY BINARY_INTEGER;
TYPE TableNomDep IS TABLE OF VARCHAR2(40);
PROCEDURE AjouterProjets(ProjetRecord IN PROJETS%ROWTYPE);
PROCEDURE SupprimerProjet(DelNumPro IN PROJETS.numpro%TYPE);
--PROCEDURE ModifierProjet(newRecord IN PROJETS%ROWTYPE, oldRecord IN PROJETS%ROWTYPE);
FUNCTION ListerEmployes(dep1 IN DEPARTEMENTS.Nomdep%TYPE, dep2 IN DEPARTEMENTS.Nomdep%TYPE) RETURN Signaletique;
END GestionProjets;
那是我有错误的函数的主体:
FUNCTION ListerEmployes(dep1 IN DEPARTEMENTS.Nomdep%TYPE, dep2 IN DEPARTEMENTS.Nomdep%TYPE) RETURN Signaletique AS
nomDeps TableNomDep;
SigTable Signaletique;
EXWrongDep1 EXCEPTION;
EXWrongDep2 EXCEPTION;
BEGIN
SELECT Nomdep
BULK COLLECT INTO nomDeps
FROM DEPARTEMENTS;
-- test if dep 1 est un parametre valide
IF NOT nomDeps.exists(dep1) THEN
RAISE EXWrongDep1;
END IF;
-- test if dep 2 est un parametre valide
IF NOT nomDeps.exists(dep2) THEN
RAISE EXWrongDep2;
END IF;
EXCEPTION
WHEN EXWrongDep1 THEN
RAISE_APPLICATION_ERROR(-20008, 'MAUVAIS PARAMETRE: ' || dep1 || ' N EXISTE PAS!');
WHEN EXWrongDep2 THEN
RAISE_APPLICATION_ERROR(-20008, 'MAUVAIS PARAMETRE: ' || dep2 || ' N EXISTE PAS!');
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR (-20007, 'ERREUR INCONNU: ' || SQLCODE || ' - ' || SQLERRM);
END ListerEmployes;
当我尝试执行该函数时,我收到以下错误消息:
DECLARE
tabel gestionprojets.Signaletique;
BEGIN
tabel := gestionprojets.listeremployes('sdsd','sdsd');
END;
ORA-20007: ERREUR INCONNU: -6502 - ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "EDGE.GESTIONPROJETS", line 108
ORA-06512: at line 4
我不明白为什么会收到此错误消息。Nomdep 列的类型是 VARCHAR2(40)。