pears.DBCleanupOrphanOLEDocument

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."DBCleanupOrphanOLEDocument" IS 
{CREATE FUNCTION DBCleanupOrphanOLEDocument 
 
/* Application Maintained Function / Procedure - DO NOT EDIT*/
 
(IN countordo CHAR(1))
RETURNS INTEGER
BEGIN
  DECLARE @RC INTEGER;
  SET @RC = 0;
  IF countordo = 'C' THEN
    SELECT COUNT(*) INTO @RC FROM OLEDocument WHERE 
     (
     ((ownertype = 'P') AND NOT EXISTS(SELECT * FROM person WHERE personid = OLEDocument.ownerid)) OR 
     ((ownertype = 'C') AND NOT EXISTS(SELECT * FROM company WHERE companyid = OLEDocument.ownerid)) OR 
     ((ownertype = 'V') AND NOT EXISTS(SELECT * FROM vacancy WHERE vacancyid = OLEDocument.ownerid)) OR 
     ((ownertype = 'R') AND NOT EXISTS(SELECT * FROM progress WHERE progressid = OLEDocument.ownerid)) OR 
     ((ownertype = 'L') AND NOT EXISTS(SELECT * FROM placement WHERE placementid = OLEDocument.ownerid)) 
     );
    RETURN @RC
  END IF;
  DELETE FROM OLEDocument WHERE(ownertype = 'P') AND
    NOT EXISTS(SELECT * FROM person WHERE personid = OLEDocument.ownerid);
  SET @RC = @RC + (SELECT @@rowcount);
  DELETE FROM OLEDocument WHERE(ownertype = 'C') AND
    NOT EXISTS(SELECT * FROM company WHERE companyid = OLEDocument.ownerid);
  SET @RC = @RC + (SELECT @@rowcount);
  DELETE FROM OLEDocument WHERE(ownertype = 'V') AND
    NOT EXISTS(SELECT * FROM vacancy WHERE vacancyid = OLEDocument.ownerid);
  SET @RC = @RC + (SELECT @@rowcount);
  DELETE FROM OLEDocument WHERE(ownertype = 'R') AND
    NOT EXISTS(SELECT * FROM progress WHERE progressid = OLEDocument.ownerid);
  SET @RC = @RC + (SELECT @@rowcount);
  DELETE FROM OLEDocument WHERE(ownertype = 'L') AND
    NOT EXISTS(SELECT * FROM placement WHERE placementid = OLEDocument.ownerid);
  SET @RC = @RC + (SELECT @@rowcount);
  CALL AuditLog('CLEANUP',NULL,string(@RC,' Unattached OLEDocument Records deleted '),NULL,NULL);
  RETURN @RC;
END
}
  • database/procedures/pears_dbcleanuporphanoledocument.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1