我有這樣的過程:範圍引發異常,處理自己的異常在PLSQL代碼
create or replace PROCEDURE CONVERTE
IS
CURSOR oldemployees IS
SELECT *
FROM emp1
WHERE data_saida= NULL;
new_ndep emp1.num_dep%type;
bi_inexistente EXCEPTION;
dep_inexistente EXCEPTION;
employeeNr emp1.num_empregado%type;
BEGIN
FOR old_emp IN oldemployees
LOOP
employeeNr:= old_emp.num_empregado;
if (old_emp.bi = NULL) then
raise bi_inexistente;
else
IF (old_emp.num_dep>20) THEN
SELECT ndep_novo INTO new_ndep FROM Converte_dep WHERE ndep_antigo= old_emp.num_dep;
elsif (old_emp.num_dep = NULL) then
new_ndep:= 0;
raise dep_inexistente;
end if;
INSERT INTO EMP2 VALUES (old_emp.bi, old_emp.nome, old_emp.morada, old_emp.data_entrada, old_emp.data_saida, new_ndep);
COMMIT;
end if;
end loop;
EXCEPTION
when bi_inexistente then
INSERT INTO ERROS VALUES(employeeNr, 'BI Inexistente');
COMMIT;
when dep_inexistente then
INSERT INTO ERROS VALUES(employeeNr, 'Departamento Inexistente');
COMMIT;
end;
我想要做的INSERT INTO EMP2 VALUES(old_emp.bi,old_emp.nome,old_emp.morada,old_emp。 data_entrada,old_emp.data_saida,new_ndep);即使在提高dep_inexistente後,但在閱讀oracle的參考後,我有點困惑;基本上,當它是空的,我不想做那個插入,否則我想插入,即使部門號是空的(我把它轉爲0)。
那麼,是代碼得到它的權利,或者我應該如何提高我的異常或辦理我的案件預先定義的異常?