annotate MySQL/Plugins/GetLastChangeIndex.sql @ 485:9722e408d817 OrthancPostgreSQL-6.0

closing OrthancPostgreSQL-6.0
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 22 Mar 2024 13:34:19 +0100
parents 740d9829f52e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;