diff --git a/5_GEONATURE/check_data.py b/5_GEONATURE/check_data.py index b158462..7d1f483 100644 --- a/5_GEONATURE/check_data.py +++ b/5_GEONATURE/check_data.py @@ -127,7 +127,29 @@ def resolve_missing_data(con): def resolve_synthese_errors(con): sql = ''' - + with t1 as ( + SELECT + --tro.*,too.* + tro.unique_id_sinp_grp + FROM pr_occtax.t_occurrences_occtax AS too + JOIN pr_occtax.t_releves_occtax tro using (id_releve_occtax) + ),t2 as ( + select + s.id_synthese, + too.id_releve_occtax, + too.id_occurrence_occtax, + too.id_nomenclature_exist_proof + FROM pr_occtax.t_occurrences_occtax AS too + JOIN pr_occtax.t_releves_occtax tro using (id_releve_occtax) + JOIN pr_occtax.cor_counting_occtax cco using (id_occurrence_occtax) + JOIN gn_synthese.synthese s on s.unique_id_sinp = cco.unique_id_sinp_occtax + WHERE tro.unique_id_sinp_grp IN (SELECT t1.unique_id_sinp_grp FROM t1) + AND (too.nom_cite != s.nom_cite) + ) + UPDATE pr_occtax.t_occurrences_occtax too + SET id_nomenclature_exist_proof = t2.id_nomenclature_exist_proof + FROM t2 + WHERE too.id_occurrence_occtax = t2.id_occurrence_occtax; ''' if __name__ == '__main__':