0 ', 'temp e_lpp' ); INSERT INTO base.t_lpp( code, texte, texte_court) SELECT code, texte, texte_court FROM e_lpp WHERE code NOT IN (SELECT code FROM base.t_lpp WHERE code IS NOT NULL); DROP TABLE IF EXISTS c_lpp; CREATE TEMP TABLE c_lpp AS SELECT e_lpp.oid AS from_oid, COALESCE(t_lpp.oid,0) AS to_oid FROM e_lpp LEFT JOIN base.t_lpp ON e_lpp.code = t_lpp.code ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM base.t_ucd WHERE oid <> 0 ', 'temp e_ucd' ); INSERT INTO base.t_ucd( code, texte, texte_court, laboratoire_texte, conditionnement_texte, atc_code, atc_texte, ephmra_code, ephmra_texte, prestation_defaut_id) SELECT code, texte, texte_court, laboratoire_texte, conditionnement_texte, atc_code, atc_texte, ephmra_code, ephmra_texte, 0 FROM e_ucd WHERE code NOT IN (SELECT code FROM base.t_ucd WHERE code IS NOT NULL); DROP TABLE IF EXISTS c_ucd; CREATE TEMP TABLE c_ucd AS SELECT e_ucd.oid AS from_oid, COALESCE(t_ucd.oid,0) AS to_oid FROM e_ucd LEFT JOIN base.t_ucd ON e_ucd.code = t_ucd.code ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_articles ', 'temp e_articles' ); TRUNCATE eco.t_articles ; INSERT INTO eco.t_articles( article_reference_cacic_code, article_reference_cacic_id, article_reference_cacic_section_code, article_reference_cacic_section_id, article_reference_cacic_section_texte, article_reference_cacic_texte, article_reference_cti_code, article_reference_cti_id, article_reference_cti_section_code, article_reference_cti_section_id, article_reference_cti_section_texte, article_reference_cti_texte, categorie_code, categorie_id, categorie_section_code, categorie_section_id, categorie_section_texte, categorie_texte, classification_atc_1_code, classification_atc_1_id, classification_atc_1_texte, classification_atc_2_code, classification_atc_2_id, classification_atc_2_texte, classification_atc_3_code, classification_atc_3_id, classification_atc_3_texte, classification_atc_4_code, classification_atc_4_id, classification_atc_4_texte, classification_atc_code, classification_atc_id, classification_atc_section_code, classification_atc_section_id, classification_atc_section_texte, classification_atc_texte, code, code_original, compte_code, compte_id, compte_section_code, compte_section_id, compte_section_texte, compte_texte, est_inactif, famille_code, famille_id, famille_section_code, famille_section_id, famille_section_texte, famille_texte, gere_en_stock, lpp_id, oid, ref_fournisseur_id, ref_fournisseur_texte, section_code, section_id, section_texte, sous_categorie_code, sous_categorie_id, sous_categorie_section_code, sous_categorie_section_id, sous_categorie_section_texte, sous_categorie_texte, sous_famille_code, sous_famille_id, sous_famille_section_code, sous_famille_section_id, sous_famille_section_texte, sous_famille_texte, texte, texte_court, type_code, type_id, type_prorata_tva, type_section_code, type_section_id, type_section_texte, type_texte, type_valorisation_cti_stock, ucd_id, unite_distribution_code, unite_distribution_id, unite_distribution_section_code, unite_distribution_section_id, unite_distribution_section_texte, unite_distribution_texte, unite_stockage_code, unite_stockage_id, unite_stockage_section_code, unite_stockage_section_id, unite_stockage_section_texte, unite_stockage_texte, fournisseur_principal_id, taux_tva_en_cours) SELECT article_reference_cacic_code, article_reference_cacic_id, article_reference_cacic_section_code, article_reference_cacic_section_id, article_reference_cacic_section_texte, article_reference_cacic_texte, article_reference_cti_code, article_reference_cti_id, article_reference_cti_section_code, article_reference_cti_section_id, article_reference_cti_section_texte, article_reference_cti_texte, categorie_code, categorie_id, categorie_section_code, categorie_section_id, categorie_section_texte, categorie_texte, classification_atc_1_code, classification_atc_1_id, classification_atc_1_texte, classification_atc_2_code, classification_atc_2_id, classification_atc_2_texte, classification_atc_3_code, classification_atc_3_id, classification_atc_3_texte, classification_atc_4_code, classification_atc_4_id, classification_atc_4_texte, classification_atc_code, classification_atc_id, classification_atc_section_code, classification_atc_section_id, classification_atc_section_texte, classification_atc_texte, code, code_original, compte_code, compte_id, compte_section_code, compte_section_id, compte_section_texte, compte_texte, est_inactif, famille_code, famille_id, famille_section_code, famille_section_id, famille_section_texte, famille_texte, gere_en_stock, COALESCE(c_lpp.to_oid,0) AS lpp_id, oid, ref_fournisseur_id, ref_fournisseur_texte, section_code, section_id, section_texte, sous_categorie_code, sous_categorie_id, sous_categorie_section_code, sous_categorie_section_id, sous_categorie_section_texte, sous_categorie_texte, sous_famille_code, sous_famille_id, sous_famille_section_code, sous_famille_section_id, sous_famille_section_texte, sous_famille_texte, texte, texte_court, type_code, type_id, type_prorata_tva, type_section_code, type_section_id, type_section_texte, type_texte, type_valorisation_cti_stock, COALESCE(c_ucd.to_oid,0) AS ucd_id, unite_distribution_code, unite_distribution_id, unite_distribution_section_code, unite_distribution_section_id, unite_distribution_section_texte, unite_distribution_texte, unite_stockage_code, unite_stockage_id, unite_stockage_section_code, unite_stockage_section_id, unite_stockage_section_texte, unite_stockage_texte, fournisseur_principal_id, taux_tva_en_cours FROM e_articles LEFT JOIN c_ucd ON ucd_id = c_ucd.from_oid LEFT JOIN c_lpp ON lpp_id = c_lpp.from_oid WHERE oid NOT IN (SELECT oid FROM eco.t_articles) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_categories_articles ', 'temp e_categories_articles' ); TRUNCATE eco.t_categories_articles ; INSERT INTO eco.t_categories_articles(code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_categories_articles WHERE oid NOT IN (SELECT oid FROM eco.t_categories_articles) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_classification_atc ', 'temp e_classification_atc' ); TRUNCATE eco.t_classification_atc; INSERT INTO eco.t_classification_atc( classification_atc_1_code, classification_atc_1_id, classification_atc_1_texte, classification_atc_2_code, classification_atc_2_id, classification_atc_2_texte, classification_atc_3_code, classification_atc_3_id, classification_atc_3_texte, classification_atc_4_code, classification_atc_4_id, classification_atc_4_texte, code, code_original, est_atc, est_cladimed, oid, section_code, section_id, section_texte, texte, texte_court) SELECT classification_atc_1_code, classification_atc_1_id, classification_atc_1_texte, classification_atc_2_code, classification_atc_2_id, classification_atc_2_texte, classification_atc_3_code, classification_atc_3_id, classification_atc_3_texte, classification_atc_4_code, classification_atc_4_id, classification_atc_4_texte, code, code_original, est_atc, est_cladimed, oid, section_code, section_id, section_texte, texte, texte_court FROM e_classification_atc WHERE oid NOT IN (SELECT oid FROM eco.t_classification_atc) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_compte ', 'temp e_compte' ); TRUNCATE eco.t_compte; INSERT INTO eco.t_compte( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte, type_prorata_tva) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte, type_prorata_tva FROM e_compte WHERE oid NOT IN (SELECT oid FROM eco.t_compte) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_familles_articles ', 'temp e_familles_articles' ); TRUNCATE eco.t_familles_articles ; INSERT INTO eco.t_familles_articles( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_familles_articles WHERE oid NOT IN (SELECT oid FROM eco.t_familles_articles) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_gestionnaires ', 'temp e_gestionnaires' ); TRUNCATE eco.t_gestionnaires ; INSERT INTO eco.t_gestionnaires( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_gestionnaires WHERE oid NOT IN (SELECT oid FROM eco.t_gestionnaires) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_lieux ', 'temp e_lieux' ); TRUNCATE eco.t_lieux ; INSERT INTO eco.t_lieux( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_lieux WHERE oid NOT IN (SELECT oid FROM eco.t_lieux) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_sous_familles_articles ', 'temp e_sous_familles_articles' ); TRUNCATE eco.t_sous_familles_articles ; INSERT INTO eco.t_sous_familles_articles( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_sous_familles_articles WHERE oid NOT IN (SELECT oid FROM eco.t_sous_familles_articles) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_sous_categories_articles ', 'temp e_sous_categories_articles' ); TRUNCATE eco.t_sous_categories_articles ; INSERT INTO eco.t_sous_categories_articles( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_sous_categories_articles WHERE oid NOT IN (SELECT oid FROM eco.t_sous_categories_articles) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_types_articles ', 'temp e_types_articles' ); TRUNCATE eco.t_types_articles ; INSERT INTO eco.t_types_articles( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_types_articles WHERE oid NOT IN (SELECT oid FROM eco.t_types_articles) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_unites ', 'temp e_unites' ); TRUNCATE eco.t_unites ; INSERT INTO eco.t_unites( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_unites WHERE oid NOT IN (SELECT oid FROM eco.t_unites) ; SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', ' SELECT * FROM eco.t_unites_fonctionnelles ', 'temp e_unites_fonctionnelles' ); TRUNCATE eco.t_unites_fonctionnelles ; INSERT INTO eco.t_unites_fonctionnelles( code, code_original, oid, texte_court, texte, section_code, section_id, section_texte) SELECT code, code_original, oid, texte_court, texte, section_code, section_id, section_texte FROM e_unites_fonctionnelles WHERE oid NOT IN (SELECT oid FROM eco.t_unites_fonctionnelles) ; ]]>