I have a package P and a precedure A in it.
create or replace package pkg_get_users_info_by_role
as
type user_info_ref_cur is ref cursor;
procedure get_user_info_proc
(p_role_name varchar2, p_user_info out user_info_ref_cur);
end pkg_get_users_info_by_role;
/
and the body;
create or replace package body pkg_get_users_info_by_role
as
procedure get_user_info_proc
(p_role_name varchar2, p_user_info out user_info_ref_cur)
as
begin
open p_user_info for
select user_id,username,user_password,role_name from user_info,role_info
where user_info.user_role=role_info.role_id
and role_info.role_name like p_role_name;
end;
end pkg_get_users_info_by_role;
My question is, how can I call the procedure? Do I need a variable of pkg_get_users_info_by_role.user_info_ref_cur type to call it? I cannot create a variable of this type. Is there any way to solve this?
Thanks!!
Yes, you simply define your cursor in your calling program as the package.type. Here’s a simple-minded illustration that should work on most any oracle database: