create or replace type emp_type_o as object
(address_line1 varchar2(240),
city varchar2(60),
state varchar2(150),
zip varchar2(60)
);
create type emp_type_t is table of emp_type_o;
PL/SQL FUNCTION:
create or replace function get_emp_list(p_segment1 varchar2)
return emp_type_t
as
v_address_line_1 emp_type_t;
begin
select emp_type_o(address_line1,city, state,zip)
bulk collect into v_address_line_1
from ap_supplier_sites_all assa,ap_suppliers aps
where assa.vendor_id = aps.vendor_id
and aps.segment1 = p_segment1;
return v_address_line_1;
end;
PL/SQL FUNCTION RUN OUTPUT:
select * from table(get_emp_list(16896));
Package Spec:
Create Or Replace Package Get_emp_address_Pkg
Is
Function get_emp_list(p_segment1 varchar2)
Return emp_type_t;
End ;
Package Body:
create or replace package body Get_emp_address_Pkg
is
function get_emp_list(p_segment1 varchar2)
return emp_type_t
as
v_address_line_1 emp_type_t;
begin
select emp_type_o(address_line1,city,state,zip)
bulk collect into v_address_line_1
from ap_supplier_sites_all assa,ap_suppliers aps
where assa.vendor_id = aps.vendor_id
and aps.segment1 = p_segment1;
return v_address_line_1;
end get_emp_list;
end get_emp_address_pkg;
Run the Package:
select get_emp_address_pkg.get_emp_list(16896) from dual;
No comments:
Post a Comment