====== pears.NetOwnerFavourites ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Original SQL =====
create procedure "pears"."NetOwnerFavourites"( in "pWebUserID" char(20),in "pStaffID" char(20) default null )
result( "favouriteID" char(20),"favouriteName" char(100),"favouriteDescription" long varchar,"favouriteType" char(10),"objectID" char(20),"parentFavouriteID" char(20),"isNode" integer )
begin
set "pStaffID" = "isnull"("nullif"("pStaffID",''),"userStaffID");
select "f"."FavouritesID" as "FavouriteID",
"NetFavouriteTitle"("FavouriteID") as "ObjTitle",
"isnull"("Description",'') as "ObjDescription",
(case "Type"
when 'H' then 'Heading'
when 'C' then 'Company'
when 'E' then 'Contact'
when 'P' then 'Person'
when 'V' then 'Vacancy'
when 'L' then 'Placement' end) as "ObjType",
"ID" as "ObjID",
"isnull"("parent",'') as "ParentID",
(select(if "count"() > 0 then 1 else 0 endif) from "favourites" as "f" where "FavouriteID" = "f"."parent") as "IsNode"
from "Favourites" as "f"
key join "staff" as "s"
where "f"."staffid" = "pStaffID" and "s"."divisionid" = any(select "divisionid" from "dashboardstaffdivisions"())
end /* DOC
2016-08-11 PC RC1 - create child list of any item
2016-08-23 PC Doc and test
2019-07-09 ET Changed procedure to return all favourite records for a given staffID (default to userStaffID if not specified)
*/
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."NetOwnerFavourites" IS
{create PROCEDURE pears."NetOwnerFavourites"(in pWebUserID char(20), in pStaffID char(20) default null)
RESULT(favouriteID char(20),favouriteName char(100),favouriteDescription long varchar,favouriteType char(10),objectID char(20),parentFavouriteID char(20),isNode integer)
BEGIN
set pStaffID = isnull(nullif(pStaffID, ''), userStaffID);
select
f.FavouritesID as FavouriteID,
NetFavouriteTitle(FavouriteID) as ObjTitle,
isnull(Description,'') as ObjDescription,
(case Type
when 'H' then 'Heading'
when 'C' then 'Company'
when 'E' then 'Contact'
when 'P' then 'Person'
when 'V' then 'Vacancy'
when 'L' then 'Placement'
end) as ObjType,
ID as ObjID,
isnull(parent,'') as ParentID,
(select (if count(*) > 0 then 1 else 0 endif)from favourites f where FavouriteID=f.parent) as IsNode
from Favourites f
key join staff s
where f.staffid = pStaffID and s.divisionid in (select divisionid from dashboardstaffdivisions())
END
/* DOC
2016-08-11 PC RC1 - create child list of any item
2016-08-23 PC Doc and test
2019-07-09 ET Changed procedure to return all favourite records for a given staffID (default to userStaffID if not specified)
*/
}