嗨,我有一项任务要解决。我写了这段代码
CREATE OR REPLACE function hr_funct_task4(p_emp_id number)
return varchar
as
v_emp_last_name varchar2(25);
v_count number;
no_emp_id exception;
null_emp_id exception;
begin
if p_emp_id is null
then
raise no_emp_id;
else
select count(*)
into v_count
from jobs j
inner join employees e
on e.job_id = j.job_id
where j.min_salary > 10000
and e.employee_id = p_emp_id;
if v_count <> 0
then
select e.last_name
into v_emp_last_name
from jobs j
inner join employees e
on e.job_id = j.job_id
where j.min_salary > 10000
and e.employee_id = p_emp_id;
else
v_emp_last_name := 'No emp_id has salsry > 10000';
end if;
end if;
return v_emp_last_name;
exception
when no_emp_id then raise_application_error(-20001, 'No emp found! Please, input another emp_id.');
when null_emp_id then raise_application_error(-20001, 'Input emp_id is null. Please, input not null value.');
end;
调用函数:
begin
for i in
(
select hr_funct_task4(e.employee_id) as last_name
from employees e
)
loop
dbms_output.put_line(i.last_name);
end loop;
end;
我收到了正确的值,但也收到了错误 06502。00000 -“PL/SQL:数字或值错误%s”,ORA-06512:第 4 行。
你能告诉我我做错了什么吗?谢谢