可以,参考如下格式
create or replace type "TYPE_USERALLORGS" AUTHID DEFINER
is
OBJECT
(
ID int,
OrgName varchar2(50),
OrgCode varchar2(20),
"Type" int,
Status int,
ParentID int,
Description varchar2(500),
FK_Id int);
CREATE OR REPLACE TYPE WT IS TABLE OF TYPE_USERALLORGS;
CREATE OR REPLACE
FUNCTION "Fun_EC_GetUserAllOrgs"
(
"userid" int)
RETURN WT
AS
/变量说明部分/
--VARNAME INT;
--type_userallorgs1 TYPE_USERALLORGS;
--declare
tb WT := WT();
i number := 0;
BEGIN
FOR v_emp in
(
select distinct * from ( select * from (select o.* from T_AC_Organization o join (select o.* from T_AC_User_Organization uo join T_AC_Organization o on uo.OrgID=o.ID where UserID=1) u on o.OrgCode like concat(u.OrgCode,'%')) userorgswithchildren union
select * from ( select o.* from T_AC_Organization o join(
select mo.ManagedOrgCode from T_AC_UserRightWithOrganization mo join (select o.* from T_AC_User_Organization uo join T_AC_Organization o on uo.OrgID=o.ID where UserID=1) u on u.OrgCode like concat(mo.OrgCode,'%')
) f on o.OrgCode like concat(f.ManagedOrgCode,'%')) managedbaseorgs)
)
loop
tb.extend;
i :=i+1 ;
tb(i):= TYPE_USERALLORGS(v_emp.ID, v_emp.ORGNAME, v_emp.ORGCODE, v_emp."TYPE", v_emp.Status, v_emp.ParentID, v_emp.ParentID, v_emp.FK_Id);
END LOOP;
return tb;
END "Fun_EC_GetUserAllOrgs";
可以,参考如下格式
create or replace type "TYPE_USERALLORGS" AUTHID DEFINER
is
OBJECT
(
ID int,
OrgName varchar2(50),
OrgCode varchar2(20),
"Type" int,
Status int,
ParentID int,
Description varchar2(500),
FK_Id int);
CREATE OR REPLACE TYPE WT IS TABLE OF TYPE_USERALLORGS;
CREATE OR REPLACE
FUNCTION "Fun_EC_GetUserAllOrgs"
(
"userid" int)
RETURN WT
AS
/变量说明部分/
--VARNAME INT;
--type_userallorgs1 TYPE_USERALLORGS;
--declare
tb WT := WT();
i number := 0;
BEGIN
FOR v_emp in
(
select distinct * from ( select * from (select o.* from T_AC_Organization o join (select o.* from T_AC_User_Organization uo join T_AC_Organization o on uo.OrgID=o.ID where UserID=1) u on o.OrgCode like concat(u.OrgCode,'%')) userorgswithchildren union
select * from ( select o.* from T_AC_Organization o join(
select mo.ManagedOrgCode from T_AC_UserRightWithOrganization mo join (select o.* from T_AC_User_Organization uo join T_AC_Organization o on uo.OrgID=o.ID where UserID=1) u on u.OrgCode like concat(mo.OrgCode,'%')
) f on o.OrgCode like concat(f.ManagedOrgCode,'%')) managedbaseorgs)
)
loop
tb.extend;
i :=i+1 ;
tb(i):= TYPE_USERALLORGS(v_emp.ID, v_emp.ORGNAME, v_emp.ORGCODE, v_emp."TYPE", v_emp.Status, v_emp.ParentID, v_emp.ParentID, v_emp.FK_Id);
END LOOP;
return tb;
END "Fun_EC_GetUserAllOrgs";