====== pears.DBCleanupOldRecentObjects ====== Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace. ===== Original SQL ===== create function "pears"."DBCleanupOldRecentObjects"( /* Application Maintained Function / Procedure - DO NOT EDIT*/ in "age" integer,in "sid" char(20),in "countordo" char(1) ) returns integer begin declare @RC integer; declare @Staff char(20); select "count"() into @RC from "RecentObjects" where "staffid" like "sid" and "LastViewed" <= current date-"age"; if "countordo" = 'C' then return @RC end if; delete from "RecentObjects" where "staffid" like "sid" and "LastViewed" <= current date-"age"; if "sid" = '%' then set @staff = 'All' else select "name" into @staff from "staff" where "staffid" = "sid" end if; call "AuditLog"('CLEANUP',"sid","string"(@RC,' Old Recent Objects deleted ',"age",' days old for ',@staff),null,null); return @RC end