Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 779 → Rev 780

/trunk/scripts/modules/cel/redempteur.sql
18,7 → 18,7
2) on exclue celles qui on un nom_ret_nn à 0, car cela peut-être légal, cf maj-201307.sql à ce propos
# donc pas de `nom_ret_nn = 0` dans la requête
3) on exclue, dans un premier temps, celles dont le référentiel n'est pas défini
AND (nom_referentiel IS NULL AND nom_referentiel = '')
AND (nom_referentiel IS NULL)
 
D'où, les 3621 observations suivantes (2206 nom_sel distincts)
SELECT id_observation, nom_sel
31,11 → 31,11
OR nt IS NULL or nt = 0
OR famille IS NULL or famille = ''
)
AND (nom_referentiel IS NOT NULL AND nom_referentiel != '')
AND (nom_referentiel IS NOT NULL)
)
 
Dans un premier temps nous travaillons avec le bdtfx, c'est à dire que
AND (nom_referentiel IS NOT NULL AND nom_referentiel != '')
AND (nom_referentiel IS NOT NULL)
devient
AND (nom_referentiel like 'bdtfx%')
soit 3597/3621 observations:
/trunk/scripts/modules/cel/maj-referentiel-201307.sql
5,7 → 5,7
Les observations problématiques sont les suivantes:
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille
FROM cel_obs
WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel != '' AND nom_sel IS NOT NULL AND nom_ret_nn IS NOT NULL;
WHERE nom_referentiel IS NULL AND nom_sel != '' AND nom_sel IS NOT NULL AND nom_ret_nn IS NOT NULL;
 
Or maj-cleanup-201307.sql reset les valeurs des observations ayant un nom_sel NULL ou '', de plus la préférence de sélection est
donné au nom_sel (incluant les synonymes) plutôt que nom_ret_nn.
12,7 → 12,7
 
La requête est donc:
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille
FROM cel_obs WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL;
FROM cel_obs WHERE nom_referentiel IS NULL AND nom_sel_nn IS NOT NULL;
=> 76486
*/
 
26,9 → 26,9
 
/* Donc nous JOINons:
-- INNER JOIN sur bdtfx: 69719
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille FROM cel_obs c INNER JOIN tb_eflore.bdtfx_v1_01 b ON (b.num_nom = c.nom_sel_nn) WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL;
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille FROM cel_obs c INNER JOIN tb_eflore.bdtfx_v1_01 b ON (b.num_nom = c.nom_sel_nn) WHERE nom_referentiel IS NULL AND nom_sel_nn IS NOT NULL;
-- INNER JOIN sur bdtxa: 79471 dont 9752 en dup (bdtxa + bdtfx), eg: 1005047
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille FROM cel_obs c INNER JOIN T_bis b ON (b.num_nom = c.nom_sel_nn) WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL;
SELECT id_observation, nom_referentiel, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, c.famille FROM cel_obs c INNER JOIN T_bis b ON (b.num_nom = c.nom_sel_nn) WHERE nom_referentiel AND nom_sel_nn IS NOT NULL;
*/
 
/* d'où GROUP BY id_observation HAVING count(id_observation) = 1 */
37,7 → 37,7
FROM cel_obs c
INNER JOIN T_bis b
ON (b.num_nom = c.nom_sel_nn)
WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL GROUP BY id_observation HAVING count(id_observation) = 1;
WHERE nom_referentiel IS NULL AND nom_sel_nn IS NOT NULL GROUP BY id_observation HAVING count(id_observation) = 1;
-- 59967, tous bdtfx...
*/
 
51,7 → 51,7
DECLARE _id_observation bigint(20) DEFAULT 0;
DECLARE _valid_ref varchar(20) DEFAULT NULL;
DECLARE cur1 CURSOR FOR SELECT id_observation, valid_ref FROM cel_obs c INNER JOIN T_bis b ON (b.num_nom = c.nom_sel_nn)
WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel_nn IS NOT NULL group by id_observation HAVING count(id_observation) = 1;
WHERE nom_referentiel IS NULL AND nom_sel_nn IS NOT NULL group by id_observation HAVING count(id_observation) = 1;
-- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
 
/trunk/scripts/modules/cel/maj-cleanup-201307.sql
8,8 → 8,10
-- referentiels: 65800 NULL, 13000 ''
UPDATE cel_obs SET nom_referentiel = SUBSTRING_INDEX(nom_referentiel, ':', 1);
UPDATE cel_obs SET nom_referentiel = 'bdtfx' WHERE nom_referentiel IN ('bdtfx_v1','bdnff');
-- TODO: UPDATE cel_obs SET nom_referentiel = NULL where nom_referentiel = '';
 
-- pas de raison historique mémorisée à une différence '' vs NULL
UPDATE cel_obs SET nom_referentiel = NULL where nom_referentiel = '';
 
-- suppression des infos générées pour les observations dont le nom_sel à été supprimé par l'utilisateur
-- 3172
UPDATE tb_cel.cel_obs c SET
18,7 → 20,7
c.nom_ret = NULL,
c.nom_ret_nn = NULL,
c.nt = NULL,
c.famille = NULL;
c.famille = NULL
WHERE nom_sel = '' OR nom_sel IS NULL;
 
-- problème n°1: mauvais référentiel (bdtfx)
/trunk/scripts/modules/cel/maj-referentiel-und-201307.sql
52,7 → 52,7
DECLARE _nom varchar(255) DEFAULT NULL;
 
-- la requête principale de sélection des observations à mettre à jour
DECLARE cur1 CURSOR FOR SELECT id_observation, nom_sel FROM cel_obs WHERE (nom_referentiel IS NULL OR nom_referentiel = '') AND nom_sel != '' AND nom_sel IS NOT NULL AND nom_ret_nn IS NULL; -- 78149
DECLARE cur1 CURSOR FOR SELECT id_observation, nom_sel FROM cel_obs WHERE nom_referentiel IS NULL AND nom_sel != '' AND nom_sel IS NOT NULL AND nom_ret_nn IS NULL; -- 78149
-- DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;