Oracle 如何使用in和output参数pl/sql获取存储过程的输出
我已经创建了一个存储过程…在这个存储过程中,获取员工的姓名、薪水和他的经理的姓名。。过程已成功创建,但在执行时给出了无效参数的错误。。如何执行此过程Oracle 如何使用in和output参数pl/sql获取存储过程的输出,oracle,stored-procedures,plsql,Oracle,Stored Procedures,Plsql,我已经创建了一个存储过程…在这个存储过程中,获取员工的姓名、薪水和他的经理的姓名。。过程已成功创建,但在执行时给出了无效参数的错误。。如何执行此过程 create or replace procedure employee_manager ( dept_id in number, fname out varchar2, v_sal out number, fname1 out varchar2 ) is begin select a.first_name manager_n
create or replace procedure employee_manager (
dept_id in number,
fname out varchar2,
v_sal out number,
fname1 out varchar2
)
is
begin
select a.first_name manager_name,
b.first_name employee_name,
b.salary
into fname,
fname1,
v_sal
from employees a join employees b on a.employee_id = b.manager_id
where a.department_id = dept_id;
end employee_manager ;
如果你告诉我们调用过程时到底发生了什么,或者——至少——发布了ORA-xxxxx错误代码,If会有所帮助。根据我们目前掌握的信息,我们只能猜测 我猜你把它叫错了。因为它接受一个IN参数和三个OUT参数,所以必须声明三个变量;大概是这样的:
declare
l_fname employees.first_name%type;
l_sal employees.salary%type;
l_fname1 employees.first_name%type;
begin
employee_manager(dept_id => 10,
fname => l_fname,
v_sal => l_sal,
fname1 => l_fname1);
dbms_output.put_line('Values returned are: ' || l_fname ||', '|| l_sal ||', '|| l_fname1);
end;
/
假设部门可以有多个员工,一旦您通过调用过程解决了问题,就会出现
太多行
异常。如果希望有标量out
参数,则需要运行一个返回单行的查询。如果要运行返回多行的查询,可以返回集合类型。但返回sys\u refcursor
可能更有意义。但我想知道,在过程中使用这些代码,而不仅仅是创建一个可以查询的视图,是否真的有意义。