Subversion Repositories eFlore/Projets.eflore-projets

Rev

Rev 760 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
755 raphael 1
/*
2
Cleanup des observation ayant un nom_ret_nn à 0 (mais un nom_ret défini...):
3
En effet, on peut pour l'instant POSTer $nom_ret, d'où bien souvent nom_sel == nom_ret, cependant nom_ret_nn = 0
4
(pas d'autodétection).
5
Nous pourrions donc les nullifier sans remord, ... mais ...
6
nom_ret == 0 est VALIDE (car bdtfx.num_nom_retenu == 0 est valide) [ 3800 nom_retenu "orphelins" de taxon ]
7
 
8
1) créer un index pour les jointures:
9
CREATE INDEX i_nom_ret ON bdtfx_v1_02 (`nom_sci`(8))
10
2) regarder les num_nom_ret orphelins de taxon en BDTFX:
11
SELECT * FROM bdtfx_v1_02 WHERE num_nom_retenu = 0; # 3960
12
3) regarder les num_nom_ret orphelins de taxon en BDTFX:
13
SELECT * FROM bdtxa_v1_00 WHERE num_nom_retenu = 0; # 0
14
4) regarder les orphelins équivalents dans cel_obs:
15
SELECT date_observation, SUBSTRING(nom_sel, 1, 50), nom_ret_nn, nom_ret, b.nom_sci FROM cel_obs c LEFT JOIN tb_eflore.bdtfx_v1_02 b on (c.nom_ret = b.nom_sci) WHERE nom_ret_nn = 0; # 7740
16
 
17
Donc ceux dont le nom_ret à été POSTé manuellement et qui matchent le nom_sci de BDTFX : on les conserve.
18
Mais les autres, qui ont un nom_ret probablement erroné et un nom_ret_nn à 0, on NULLify les données censées être (correctement) autogénérées !
19
 
20
Cela concerne:
21
SELECT date_observation, SUBSTRING(nom_sel, 1, 50), nom_ret_nn, nom_ret, b.nom_sci FROM cel_obs c LEFT JOIN tb_eflore.bdtfx_v1_02 b on (c.nom_ret = b.nom_sci) WHERE nom_ret_nn = 0
22
 AND c.nom_ret != '' AND id_observation NOT IN ( SELECT id_observation FROM cel_obs c, tb_eflore.bdtfx_v1_02 b WHERE c.nom_ret = b.nom_sci AND c.nom_ret_nn = 0 );  # 960
23
*/
24
-- D'où la requête :
25
UPDATE cel_obs SET nom_sel_nn = NULL, nom_ret = NULL, nom_ret_nn = NULL, nt = NULL, famille = NULL WHERE id_observation IN
26
( SELECT id_observation FROM cel_obs c LEFT JOIN tb_eflore.bdtfx_v1_02 b on (c.nom_ret = b.nom_sci) WHERE nom_ret_nn = 0
27
 AND c.nom_ret != '' AND id_observation NOT IN ( SELECT id_observation FROM cel_obs c, tb_eflore.bdtfx_v1_02 b WHERE c.nom_ret = b.nom_sci AND c.nom_ret_nn = 0 ) );
28
 
29
-- TODO
30
-- UPDATE cel_obs SET nom_ret_nn = NULL WHERE nom_ret_nn = 0;
31
-- UPDATE cel_obs SET nom_sel_nn = NULL WHERE nom_sel_nn = 0;
32
 
33
/*
34
UPDATE cel_obs SET nom_sel = NULL, nom_sel_nn = NULL, nom_ret = NULL, nom_ret_nn = NULL, nt = NULL, famille = NULL,
35
	FROM cel_obs
36
	WHERE (nom_sel = '' OR nom_sel IS NULL) AND
37
	(
38
	(nom_ret IS NOT NULL AND nom_ret != '') OR
39
	(nom_ret_nn IS NOT NULL AND nom_ret_nn != 0 AND nom_ret_nn != '') OR
40
	(nt IS NOT NULL AND nt != 0 AND nt != '') OR
41
	(famille IS NOT NULL AND famille != '')
42
	)
43
*/
44