I created a plsql program to get an employee_id from substitution variable. whenever i try to input a letter, i get an error message with ORA-06550 as the error number. I put it in the exception section but it seems like it wasn’t being raised.
here’s the error message when i input ‘kk’ in the substitution variable…
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:
and here’s my pl/sql block
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;
/
do anyone knows why i cant trap that exception?
I wish I could comment. Can’t you change your code to:
so you won’t need to trap that exception.
Update for catching number exception: