Mercurial > hg > orthanc-databases
diff PostgreSQL/Plugins/ResourceDeletedFunc.sql @ 433:5964ce6385a5 pg-transactions
use temporary tables for DeletedFiles, RemainingAncestor and DeletedResources
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 13 Dec 2023 15:48:56 +0100 |
parents | 8b7c1c423367 |
children | 23c7af6f671a |
line wrap: on
line diff
--- a/PostgreSQL/Plugins/ResourceDeletedFunc.sql Mon Dec 11 14:39:27 2023 +0100 +++ b/PostgreSQL/Plugins/ResourceDeletedFunc.sql Wed Dec 13 15:48:56 2023 +0100 @@ -11,7 +11,7 @@ -- If this resource still has siblings, keep track of the remaining parent -- (a parent that must not be deleted but whose LastUpdate must be updated) - INSERT INTO RemainingAncestor SELECT resourceType, publicId + INSERT INTO RemainingAncestor SELECT resourceType, publicId FROM Resources WHERE internalId = old.parentId AND EXISTS (SELECT 1 FROM Resources WHERE parentId = old.parentId); @@ -26,3 +26,8 @@ AFTER DELETE ON Resources FOR EACH ROW EXECUTE PROCEDURE ResourceDeletedFunc(); + +-- we'll now use temporary tables so we need to remove the old tables ! +DROP TABLE IF EXISTS DeletedFiles; +DROP TABLE IF EXISTS RemainingAncestor; +DROP TABLE IF EXISTS DeletedResources;