====== pears.BlobstoreProcessDeleteQueue ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Description =====
Process external blob files awaiting deletion. Called by a database event.
===== Original SQL =====
create procedure "pears"."BlobstoreProcessDeleteQueue"() no result set
/* Application Maintained Function / Procedure - DO NOT EDIT*/
begin
-- Get list of files not yet deleted
for "FileLoop" as "FileCursor" no scroll cursor for
select "BlobStoreDeleteQueueID" as "deleteID","ExternalFilePath" as "ExtFilePath" from "BlobStoreDeleteQueue" where "WhenDeleted" is null order by "BlobStoreDeleteQueueID" asc for read only
do
-- Delete waiting files if not referenced by other BlobStore Records
if not exists(select * from "BlobStore" where "BlobStore"."ExternalFilePath" = "ExtFilePath") then
call "BlobstoreDeleteExternal"("ExtFilePath")
end if;
update "BlobStoreDeleteQueue" set "WhenDeleted" = current timestamp where "BlobStoreDeleteQueue"."BlobStoreDeleteQueueID" = "deleteID"
end for;
-- Clean out processed queue items more than 14 days old
delete from "BlobStoreDeleteQueue" where "WhenDeleted" < "dateadd"("day",-14,current timestamp)
end
go
COMMENT ON PROCEDURE "pears"."BlobstoreProcessDeleteQueue" IS
'Process external blob files awaiting deletion. Called by a database event.'
go
COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."BlobstoreProcessDeleteQueue" IS
{create procedure BlobstoreProcessDeleteQueue
/* Application Maintained Function / Procedure - DO NOT EDIT*/
()
NO RESULT SET
begin
-- Get list of files not yet deleted
FOR FileLoop as FileCursor NO SCROLL CURSOR
FOR select BlobStoreDeleteQueueID as deleteID, ExternalFilePath as ExtFilePath from BlobStoreDeleteQueue where WhenDeleted is null order by BlobStoreDeleteQueueID asc
FOR READ ONLY DO
-- Delete waiting files if not referenced by other BlobStore Records
if not exists (select * from BlobStore where BlobStore.ExternalFilePath = ExtFilePath)then
call BlobstoreDeleteExternal(ExtFilePath);
end if;
update BlobStoreDeleteQueue set WhenDeleted = current timestamp where BlobStoreDeleteQueue.BlobStoreDeleteQueueID = deleteID;
END FOR;
-- Clean out processed queue items more than 14 days old
delete from BlobStoreDeleteQueue where WhenDeleted < dateadd(day,-14,current timestamp);
END
}