Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/InstallTrackAttachmentsSize.sql @ 4044:d25f4c0fa160 framework
splitting code into OrthancFramework and OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 20:30:34 +0200 |
parents | OrthancServer/Database/InstallTrackAttachmentsSize.sql@61da3c9b4121 |
children | 28944db5318b |
comparison
equal
deleted
inserted
replaced
4043:6c6239aec462 | 4044:d25f4c0fa160 |
---|---|
1 CREATE TABLE GlobalIntegers( | |
2 key INTEGER PRIMARY KEY, | |
3 value INTEGER); | |
4 | |
5 INSERT INTO GlobalProperties VALUES (6, 1); -- GlobalProperty_GetTotalSizeIsFast | |
6 | |
7 INSERT INTO GlobalIntegers SELECT 0, IFNULL(SUM(compressedSize), 0) FROM AttachedFiles; | |
8 INSERT INTO GlobalIntegers SELECT 1, IFNULL(SUM(uncompressedSize), 0) FROM AttachedFiles; | |
9 | |
10 CREATE TRIGGER AttachedFileIncrementSize | |
11 AFTER INSERT ON AttachedFiles | |
12 BEGIN | |
13 UPDATE GlobalIntegers SET value = value + new.compressedSize WHERE key = 0; | |
14 UPDATE GlobalIntegers SET value = value + new.uncompressedSize WHERE key = 1; | |
15 END; | |
16 | |
17 CREATE TRIGGER AttachedFileDecrementSize | |
18 AFTER DELETE ON AttachedFiles | |
19 BEGIN | |
20 UPDATE GlobalIntegers SET value = value - old.compressedSize WHERE key = 0; | |
21 UPDATE GlobalIntegers SET value = value - old.uncompressedSize WHERE key = 1; | |
22 END; |