Subversion Repositories eFlore/Projets.eflore-projets

Compare Revisions

Ignore whitespace Rev 891 → Rev 892

/trunk/scripts/modules/cel/referonosaure.sql
8,10 → 8,8
est conservée (même dans certains cas celle-ci a légitimement changé) et que
la première partie du nom_sel correspond toujours à la première partie du nouveau nom_sci
qui serait attribué.
*/
 
--- la requête ---
/*
-- la requête --
-- SELECT id_observation, b.num_nom, CONCAT(b.nom_sci, ' ', b.auteur), b.num_taxonomique, b.famille
SELECT id_observation, nom_ret, nom_ret_nn, nt, c.famille
FROM `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b
21,27 → 19,91
AND nom_sel_nn = num_nom
)
ORDER BY id_observation asc;
 
 
Cependant le nom_sel_nn n'est pas directement le num_num du taxon dont le nom est
retenu. Pour cela, une jointure en bdtfx sur num_nom_retenu est nécessaire et c'est
ce dernier taxon dont le num_nom est utilisé pour nom_ret_nn.
Cependant il peut aussi être vide (si aucun nom_retenu "officiel" n'existe).
 
Attention, les nom_sel_nn = 0 doivent avoir disparus de cel_obs *AU PRÉALABLE*
cf: maj-cleanup-201307.sql
*/
 
--- l'update ---
 
 
/* test:
SELECT c.nom_ret_nn, c.nom_ret, b.nom_sci, b.auteur, c.famille, b.famille, c.nt, b.num_taxonomique
FROM cel_obs c, tb_eflore.bdtfx_v1_01 b
WHERE (
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0
AND nom_referentiel = 'bdtfx'
AND nom_ret_nn = num_nom
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL)
AND (c.famille != b.famille OR c.nom_ret != CONCAT(b.nom_sci, ' ', b.auteur) OR c.nt != b.num_taxonomique)
);
= 2 taxons: 75134 et 75468 (changement de nt)
*/
 
-- l'update BDTFX avec nom_sel_nn et nom_ret_nn corrects
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b SET
c.nom_ret = CONCAT(b.nom_sci, ' ', b.auteur),
c.nt = b.num_taxonomique,
c.famille = b.famille
WHERE (
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0
AND nom_referentiel = 'bdtfx'
AND nom_ret_nn = num_nom
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL)
);
-- 339
 
/* test:
SELECT c.nom_ret_nn, c.nom_ret, bLAST.num_nom, bLAST.nom_sci, bLAST.auteur, c.famille, bLAST.famille, c.nt, bLAST.num_taxonomique
FROM cel_obs c, tb_eflore.bdtfx_v1_01 b, tb_eflore.bdtfx_v1_01 bLAST
WHERE (
bLAST.num_nom = b.num_nom_retenu
AND nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 AND nom_referentiel = 'bdtfx'
AND nom_ret_nn = bLAST.num_nom
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL)
AND (c.famille != b.famille OR c.nom_ret != CONCAT(bLAST.nom_sci, ' ', bLAST.auteur) OR c.nt != b.num_taxonomique OR c.nom_ret_nn != bLAST.num_nom)
);
*/
 
-- l'update BDTFX avec nom_sel_nn seul
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTFX` b, `BASESOURCE`.`TABLEBDTFX` b_nom_ret SET
c.nom_ret = CONCAT(b_nom_ret.nom_sci, ' ', b_nom_ret.auteur),
c.nom_ret_nn = b.num_nom,
c.nt = b.num_taxonomique,
c.famille = b.famille
WHERE (
nom_sel_nn IS NOT NULL
b_nom_ret.num_nom = b.num_nom_retenu
AND nom_sel_nn IS NOT NULL
AND nom_referentiel = 'bdtfx'
AND nom_sel_nn = num_nom
AND LOWER(c.famille) = LOWER(b.famille)
AND nom_sel_nn = b.num_nom
AND (LOWER(c.famille) = LOWER(b.famille) OR c.famille IS NULL)
AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(b.nom_sci, ' ', 1)
);
-- 31739 sans les restrictions sur famille et SUBSTRING_INDEX()
-- 31524 avec les restrictions sur famille et SUBSTRING_INDEX()
-- 251 avec indirection num_nom_retenu
 
 
-- l'update BDTXA avec nom_sel_nn et nom_ret_nn corrects --
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTXA` a SET
c.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur),
c.nt = a.num_tax,
c.famille = a.famille
WHERE (
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0
AND nom_referentiel = 'bdtxa'
AND nom_ret_nn = num_nom
AND (LOWER(c.famille) = LOWER(a.famille) OR c.famille IS NULL)
);
-- 1
 
/*TODO
-- l'update BDTXA avec nom_sel_nn seul
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEBDTXA` a SET
c.nom_ret = CONCAT(a.nom_sci, ' ', a.auteur),
c.nom_ret_nn = a.num_nom,
c.nt = a.num_tax,
c.famille = a.famille
49,14 → 111,31
nom_sel_nn IS NOT NULL
AND nom_referentiel = 'bdtxa'
AND nom_sel_nn = num_nom
AND LOWER(c.famille) = LOWER(a.famille)
AND (LOWER(c.famille) = LOWER(a.famille) OR c.famille IS NULL)
AND SUBSTRING_INDEX(c.nom_sel, ' ', 1) = SUBSTRING_INDEX(a.nom_sci, ' ', 1)
);
-- 49 sans les restrictions sur famille et SUBSTRING_INDEX()
-- 47 avec les restrictions sur famille et SUBSTRING_INDEX()
*/
 
 
-- l'update ISFAN avec nom_sel_nn et nom_ret_nn corrects --
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEISFAN` i SET
c.nom_ret = CONCAT(i.nom_sci, ' ', i.auteur),
c.nt = i.num_taxonomique,
c.famille = i.famille
WHERE (
nom_sel_nn IS NOT NULL AND nom_ret_nn IS NOT NULL AND nom_ret_nn != 0
AND nom_referentiel = 'isfan'
AND nom_ret_nn = num_nom
AND (LOWER(c.famille) = LOWER(i.famille) OR c.famille IS NULL)
);
-- 2
 
/*TODO
-- l'update ISFAN avec nom_sel_nn seul
UPDATE `BASEEDIT`.`cel_obs` c, `BASESOURCE`.`TABLEISFAN` i SET
c.nom_ret = CONCAT(i.nom_sci, ' ', i.auteur),
c.nom_ret_nn = i.num_nom,
c.nt = i.num_taxonomique,
c.famille = i.famille
64,9 → 143,10
nom_sel_nn IS NOT NULL
AND nom_referentiel = 'isfan'
AND nom_sel_nn = num_nom
AND (LOWER(c.famille) = LOWER(i.famille) OR c.famille IS NULL)
);
*/
 
 
/*
Pour observer les différences:
wdiff -w '$(tput bold;tput setaf 1)' -x '$(tput sgr0)' -y '$(tput bold;tput setaf 2)' -z '$(tput sgr0)' pre.log post.log | \