Mercurial > hg > orthanc-databases
annotate MySQL/Plugins/GetLastChangeIndex.sql @ 185:7c46155b5bb4
fix mingw build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 16 Dec 2020 13:59:17 +0100 |
parents | 740d9829f52e |
children |
rev | line source |
---|---|
144
740d9829f52e
handling of errors if MySQL user cannot CREATE TRIGGER
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
1 CREATE TABLE IF NOT EXISTS GlobalIntegers( |
87
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 property INTEGER PRIMARY KEY, |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 value BIGINT |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 ); |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 |
144
740d9829f52e
handling of errors if MySQL user cannot CREATE TRIGGER
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
7 DELETE FROM GlobalIntegers WHERE property = 0; |
740d9829f52e
handling of errors if MySQL user cannot CREATE TRIGGER
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
8 |
87
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 INSERT INTO GlobalIntegers |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 SELECT 0, COALESCE(MAX(seq), 0) FROM Changes; |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 |
144
740d9829f52e
handling of errors if MySQL user cannot CREATE TRIGGER
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
13 DROP TRIGGER IF EXISTS ChangeAdded; |
740d9829f52e
handling of errors if MySQL user cannot CREATE TRIGGER
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
87
diff
changeset
|
14 |
87
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 CREATE TRIGGER ChangeAdded |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 AFTER INSERT ON Changes |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 FOR EACH ROW |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 BEGIN |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 UPDATE GlobalIntegers SET value = new.seq WHERE property = 0@ |
48d445f756db
new extension implemented for MySQL: GetLastChangeIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 END; |