Browse Source

script création des fonctions sur les séquences

Rajah 1 year ago
parent
commit
d6dc3b8a89
2 changed files with 33 additions and 7 deletions
  1. 25 0
      mysql/create_sequences.sql
  2. 8 7
      mysql/create_tables.sql

+ 25 - 0
mysql/create_sequences.sql

@@ -0,0 +1,25 @@
+
+DELIMITER ;;
+
+DROP PROCEDURE IF EXISTS `setval`;;
+SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION";;
+CREATE DEFINER =`vote`@`localhost` PROCEDURE `setval`(seq_name VARCHAR(100), cur_val INTEGER)
+BEGIN
+  UPDATE vote.sequences SET sequence_cur_value = cur_val  WHERE sequence_name = seq_name;
+END;;
+
+DROP FUNCTION IF EXISTS `nextval`;;
+SET SESSION SQL_MODE="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION";;
+CREATE DEFINER=`vote`@`localhost` FUNCTION `nextval`(seq_name VARCHAR(100)) RETURNS bigint(20)
+BEGIN
+DECLARE cur_val bigint(20);
+SET seq_name = UPPER(seq_name);
+SELECT sequence_cur_value INTO cur_val FROM vote.sequences WHERE sequence_name = seq_name FOR UPDATE;
+IF cur_val IS NULL THEN
+IF seq_name IS NOT NULL THEN INSERT INTO vote.sequences (sequence_name) VALUES (seq_name); END IF;
+ELSE
+UPDATE vote.sequences SET sequence_cur_value = IF ((sequence_cur_value + sequence_increment) > sequence_max_value, IF (sequence_cycle = TRUE, sequence_min_value, NULL), sequence_cur_value + sequence_increment) WHERE sequence_name = seq_name;
+END IF;
+SELECT sequence_cur_value INTO cur_val FROM vote.sequences WHERE sequence_name = seq_name;
+RETURN cur_val;
+END;;

+ 8 - 7
mysql/create_tables.sql

@@ -7,7 +7,7 @@
 #
 # Hôte: 127.0.0.1 (MySQL 5.7.26)
 # Base de données: Vote
-# Temps de génération: 2019-07-12 20:53:12 +0000
+# Temps de génération: 2019-07-12 23:54:20 +0000
 # ************************************************************
 
 
@@ -136,14 +136,14 @@ LOCK TABLES `EVENEMENTS` WRITE;
 
 INSERT INTO `EVENEMENTS` (`DCRE_EVT`, `DMOD_EVT`, `INO_EVT`, `CLIB_EVT`, `CACT_EVT`, `CSCR_EVT`, `CNOM_EVT`, `IPERE_EVT`, `INIV_EVT`, `IORD_EVT`, `LACT_EVT`)
 VALUES
-	('2019-07-10 23:54:03','0000-00-00 00:00:00',1,'<i class=\"fas fa-home\"></i>&nbsp;Accueil','../servlet/menu?ttt=10100','dummy()','Accueil',0,1,0,1),
+	('2019-07-13 01:46:13','0000-00-00 00:00:00',1,'<i class=\"fas fa-home\"></i>&nbsp;Accueil','../servlet/menu?ttt=10100','dummy()','Accueil',0,1,100,1),
 	('2019-07-10 23:55:33','0000-00-00 00:00:00',3,'<i class=\"fas fa-id-card-alt\"></i>&nbsp;Données personnelles','../servlet/appli?ttt=10760','dummy()','Informations personnelles',0,1,500,1),
-	('2019-07-10 23:55:52','0000-00-00 00:00:00',4,'<i class=\"fas fa-sign-out-alt\"></i>&nbsp;Se déconnecter','../servlet/acces?ttt=10002','dummy()','Quitter',0,1,20000,1),
+	('2019-07-13 01:46:52','0000-00-00 00:00:00',4,'<i class=\"fas fa-sign-out-alt\"></i>&nbsp;Se déconnecter','../servlet/acces?ttt=10002','dummy()','Quitter',0,1,99999,1),
 	('2019-07-10 23:56:31','0000-00-00 00:00:00',6,'<i class=\"fas fa-cogs\"></i>&nbsp;Paramétrages','javascript:dummy()','bascule(6)','Paramétrages',0,1,9000,1),
-	('2019-07-11 00:00:03','0000-00-00 00:00:00',7,'<i class=\"fas fa-sliders-h\"></i>&nbsp;Environnement','../servlet/appli?ttt=10703','dummy()','Paramétrages > Variables d\'environnement',6,2,0,1),
+	('2019-07-13 01:52:17','0000-00-00 00:00:00',7,'<i class=\"fas fa-sliders-h\"></i>&nbsp;Environnement','../servlet/appli?ttt=10703','dummy()','Paramétrages > Variables d\'environnement',6,2,9100,1),
 	('2019-07-10 23:56:54','0000-00-00 00:00:00',9,'<i class=\"fas fa-users\"></i>&nbsp;Participants','../servlet/appli?ttt=10740','dummy()','Participants',0,1,2000,1),
-	('2019-07-11 00:02:04','0000-00-00 00:00:00',10,'<i class=\"fas fa-shield-alt\"></i>&nbsp;Droits','../servlet/appli?ttt=10750','dummy()','Paramétrages > Droits',6,2,3000,1),
-	('2019-07-11 00:02:29','0000-00-00 00:00:00',11,'<i class=\"fas fa-users-cog\"></i>&nbsp;Profils','../servlet/appli?ttt=10730','dummy()','Paramétrages > Profils',6,2,1000,1),
+	('2019-07-13 01:52:32','0000-00-00 00:00:00',10,'<i class=\"fas fa-shield-alt\"></i>&nbsp;Droits','../servlet/appli?ttt=10750','dummy()','Paramétrages > Droits',6,2,9300,1),
+	('2019-07-13 01:52:24','0000-00-00 00:00:00',11,'<i class=\"fas fa-users-cog\"></i>&nbsp;Profils','../servlet/appli?ttt=10730','dummy()','Paramétrages > Profils',6,2,9200,1),
 	('2019-07-11 00:07:59','0000-00-00 00:00:00',12,'<i class=\"fas fa-save\"></i>&nbsp;Productions','../servlet/prod?ttt=10610','dummy()','Productions',0,1,3000,1),
 	('2019-07-11 00:04:26','0000-00-00 00:00:00',13,'<i class=\"fas fa-layer-group\"></i>&nbsp;Catégories','../servlet/compo?ttt=10710','dummy()','Catégories',0,1,4000,1),
 	('2019-07-11 00:01:22','0000-00-00 00:00:00',14,'<i class=\"fas fa-vote-yea\"></i>&nbsp;Voter','../servlet/vote?ttt=10810','dummy()','Voter',0,1,5000,1),
@@ -194,7 +194,8 @@ VALUES
 	('2019-07-11 00:42:09','2019-07-11 00:42:09',19,'LIBELLE_LONG_JOUR2','Samedi 2 Novembre','Application',''),
 	('2019-07-11 00:42:21','2019-07-11 00:42:21',20,'LIBELLE_LONG_JOUR3','Dimanche 3 Novembre','Application',''),
 	('2019-07-11 00:29:03','2019-07-11 00:29:03',21,'LISTE_PROFILS_MAX','100','Navigation',NULL),
-	('2019-07-11 00:29:07','2019-07-11 00:29:07',22,'LISTE_VARIABLES_MAX','100','Navigation',NULL);
+	('2019-07-11 00:29:07','2019-07-11 00:29:07',22,'LISTE_VARIABLES_MAX','100','Navigation',NULL),
+	('2019-07-13 01:36:21','2019-07-13 01:36:21',23,'TAILLE_LIMITE_STOCKAGE_BASE','4','Productions','(en Mo)');
 
 /*!40000 ALTER TABLE `INITIALISATION` ENABLE KEYS */;
 UNLOCK TABLES;