我创建了一个 plsql 程序来从替换变量中获取一个employee_id。每当我尝试输入字母时,我都会收到一条错误消息,其中 ORA-06550 作为错误号。我把它放在异常部分,但它似乎没有被提出。
这是我在替换变量中输入“kk”时的错误消息...
Error report:
ORA-06550: line 13, column 9:
PLS-00201: identifier 'KK' must be declared
ORA-06550: line 13, column 1:
PL/SQL: Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:
这是我的 pl/sql 块
set serveroutput on
set verify off
declare
cursor cur(mid employees.employee_id%type) is
select e.last_name employee,
m.last_name manager
from employees e
join employees m
on m.employee_id = e.manager_id
where m.employee_id=mid;
rec cur%rowtype;
m_id employees.employee_id%type;
ex exception;
pragma exception_init(ex, -06550);
begin
m_id := &id;
open cur(m_id);
fetch cur into rec;
dbms_output.put_line('here '||rec.employee || ' ' || rec.manager);
close cur;
exception
when ex then dbms_output.put_line('employee_id was not a valid number');
end;
/
有谁知道为什么我不能捕获该异常?