return: text
lang: plpgsql
parameters:
  p0:
    type: text
    name: i_table_code
src: |
  DECLARE	
  	
  	
  	
  	result TEXT;
  BEGIN
  	
  	
  		IF (i_table_code = 'ART' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_articles', 'ART','');
  		END IF;
  		
  		IF (i_table_code = 'CAA' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_categories_articles', 'CAA','');
  		END IF;
  		IF (i_table_code = 'SCA' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_sous_categories_articles', 'SCA','');
  		END IF;
  		IF (i_table_code = 'FAA' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_familles_articles', 'FAA','');
  		END IF;
  		IF (i_table_code = 'SFA' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_sous_familles_articles', 'SFA','');
  		END IF;
  		IF (i_table_code = 'TYA' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_types_articles', 'TYA','');
  		END IF;
  		IF (i_table_code = 'SIT' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_sites', 'SIT','');
  		END IF;
  		IF (i_table_code = 'GES' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_gestionnaires', 'GES','');
  		END IF;
  		IF (i_table_code = 'LIE' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_lieux', 'LIE','');
  		END IF;
  		IF (i_table_code = 'TYF' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_types_fournisseurs', 'TYF','');
  		END IF;
  		IF (i_table_code = 'FOU' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_fournisseurs', 'FOU','');
  		END IF;
  		IF (i_table_code = 'TYM' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_types_mouvements', 'TYM','');
  		END IF;
  		IF (i_table_code = 'UFO' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_unites_fonctionnelles', 'UFO','');
  		END IF;
  		IF (i_table_code = 'UNI' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_unites', 'UNI','');
  		END IF;
  		IF (i_table_code = 'CPT' OR i_table_code = '*ALL') THEN
  			PERFORM base.cti_update_classes('eco', 't_compte', 'CPT','');
  		END IF;
  		
  		IF i_table_code IN ('*ALL', 'CAA', 'SCA', 'FAA', 'SFA', 'TYA', 'UNI') THEN
  				
  			UPDATE eco.t_articles SET
  				type_code = t_types_articles.code,
  				type_texte = t_types_articles.texte_court,
  				type_section_id = t_types_articles.section_id,
  				type_section_code = t_types_articles.section_code,
  				type_section_texte = t_types_articles.section_texte,
  				
  				famille_code = t_familles_articles.code,
  				famille_texte = t_familles_articles.texte_court,
  				famille_section_id = t_familles_articles.section_id,
  				famille_section_code = t_familles_articles.section_code,
  				famille_section_texte = t_familles_articles.section_texte,
  				sous_famille_code = t_sous_familles_articles.code,
  				sous_famille_texte = t_sous_familles_articles.texte_court,
  				sous_famille_section_id = t_sous_familles_articles.section_id,
  				sous_famille_section_code = t_sous_familles_articles.section_code,
  				sous_famille_section_texte = t_sous_familles_articles.section_texte,
  				categorie_code = t_categories_articles.code,
  				categorie_texte = t_categories_articles.texte_court,
  				categorie_section_id = t_categories_articles.section_id,
  				categorie_section_code = t_categories_articles.section_code,
  				categorie_section_texte = t_categories_articles.section_texte,
  				sous_categorie_code = t_sous_categories_articles.code,
  				sous_categorie_texte = t_sous_categories_articles.texte_court,
  				sous_categorie_section_id = t_sous_categories_articles.section_id,
  				sous_categorie_section_code = t_sous_categories_articles.section_code,
  				sous_categorie_section_texte = t_sous_categories_articles.section_texte,
  				classification_atc_code = t_classification_atc.code,
  				classification_atc_texte = t_classification_atc.texte_court,
  				classification_atc_section_id = t_classification_atc.section_id,
  				classification_atc_section_code = t_classification_atc.section_code,
  				classification_atc_section_texte = t_classification_atc.section_texte,
  				classification_atc_1_id = t_classification_atc.classification_atc_1_id,
  				classification_atc_1_code = t_classification_atc.classification_atc_1_code,
  				classification_atc_1_texte = t_classification_atc.classification_atc_1_texte,
  				classification_atc_2_id = t_classification_atc.classification_atc_2_id,
  				classification_atc_2_code = t_classification_atc.classification_atc_2_code,
  				classification_atc_2_texte = t_classification_atc.classification_atc_2_texte,
  				classification_atc_3_id = t_classification_atc.classification_atc_3_id,
  				classification_atc_3_code = t_classification_atc.classification_atc_3_code,
  				classification_atc_3_texte = t_classification_atc.classification_atc_3_texte,
  				classification_atc_4_id = t_classification_atc.classification_atc_4_id,
  				classification_atc_4_code = t_classification_atc.classification_atc_4_code,
  				classification_atc_4_texte = t_classification_atc.classification_atc_4_texte,
  				unite_stockage_code = t_unites_stockage.code,
  				unite_stockage_texte = t_unites_stockage.texte_court,
  				unite_stockage_section_id = t_unites_stockage.section_id,
  				unite_stockage_section_code = t_unites_stockage.section_code,
  				unite_stockage_section_texte = t_unites_stockage.section_texte,
  				unite_distribution_code = t_unites_distribution.code,
  				unite_distribution_texte = t_unites_distribution.texte_court,
  				unite_distribution_section_id = t_unites_distribution.section_id,
  				unite_distribution_section_code = t_unites_distribution.section_code,
  				unite_distribution_section_texte = t_unites_distribution.section_texte,
  				
  				compte_code = t_compte.code,
  				compte_texte = t_compte.texte_court,
  				compte_section_id = t_compte.section_id,
  				compte_section_code = t_compte.section_code,
  				compte_section_texte = t_compte.section_texte
  			FROM eco.t_types_articles ,
  				eco.t_familles_articles,
  				eco.t_sous_familles_articles,
  				eco.t_categories_articles,
  				eco.t_sous_categories_articles,
  				eco.t_classification_atc,
  				eco.t_unites t_unites_stockage,
  				eco.t_unites t_unites_distribution,
  				eco.t_compte
  				
  			WHERE type_id = t_types_articles.oid
  				AND famille_id = t_familles_articles.oid
  				AND sous_famille_id = t_sous_familles_articles.oid
  				AND categorie_id = t_categories_articles.oid
  				AND sous_categorie_id = t_sous_categories_articles.oid
  				AND classification_atc_id = t_classification_atc.oid
  				AND unite_stockage_id = t_unites_stockage.oid
  				AND unite_distribution_id = t_unites_distribution.oid
  				AND compte_id = t_compte.oid
  				AND (
  					type_code IS DISTINCT FROM t_types_articles.code OR
  					type_texte IS DISTINCT FROM t_types_articles.texte_court OR
  					type_section_id IS DISTINCT FROM t_types_articles.section_id OR
  					type_section_code IS DISTINCT FROM t_types_articles.section_code OR
  					type_section_texte IS DISTINCT FROM t_types_articles.section_texte OR
  					
  					famille_code IS DISTINCT FROM t_familles_articles.code OR
  					famille_texte IS DISTINCT FROM t_familles_articles.texte_court OR
  					famille_section_id IS DISTINCT FROM t_familles_articles.section_id OR
  					famille_section_code IS DISTINCT FROM t_familles_articles.section_code OR
  					famille_section_texte IS DISTINCT FROM t_familles_articles.section_texte OR
  					
  					sous_famille_code IS DISTINCT FROM t_sous_familles_articles.code OR
  					sous_famille_texte IS DISTINCT FROM t_sous_familles_articles.texte_court OR
  					sous_famille_section_id IS DISTINCT FROM t_sous_familles_articles.section_id OR
  					sous_famille_section_code IS DISTINCT FROM t_sous_familles_articles.section_code OR
  					sous_famille_section_texte IS DISTINCT FROM t_sous_familles_articles.section_texte OR
  					
  					categorie_code IS DISTINCT FROM t_categories_articles.code OR
  					categorie_texte IS DISTINCT FROM t_categories_articles.texte_court OR
  					categorie_section_id IS DISTINCT FROM t_categories_articles.section_id OR
  					categorie_section_code IS DISTINCT FROM t_categories_articles.section_code OR
  					categorie_section_texte IS DISTINCT FROM t_categories_articles.section_texte OR
  					
  					sous_categorie_code IS DISTINCT FROM t_sous_categories_articles.code OR
  					sous_categorie_texte IS DISTINCT FROM t_sous_categories_articles.texte_court OR
  					sous_categorie_section_id IS DISTINCT FROM t_sous_categories_articles.section_id OR
  					sous_categorie_section_code IS DISTINCT FROM t_sous_categories_articles.section_code OR
  					sous_categorie_section_texte IS DISTINCT FROM t_sous_categories_articles.section_texte OR
  					
  					t_articles.classification_atc_code IS DISTINCT FROM t_classification_atc.code OR
  					t_articles.classification_atc_texte IS DISTINCT FROM t_classification_atc.texte_court OR
  					t_articles.classification_atc_section_id IS DISTINCT FROM t_classification_atc.section_id OR
  					t_articles.classification_atc_section_code IS DISTINCT FROM t_classification_atc.section_code OR
  					t_articles.classification_atc_section_texte IS DISTINCT FROM t_classification_atc.section_texte OR
  					t_articles.classification_atc_1_id IS DISTINCT FROM t_classification_atc.classification_atc_1_id OR
  					t_articles.classification_atc_1_code IS DISTINCT FROM t_classification_atc.classification_atc_1_code OR
  					t_articles.classification_atc_1_texte IS DISTINCT FROM t_classification_atc.classification_atc_1_texte OR
  					t_articles.classification_atc_2_id IS DISTINCT FROM t_classification_atc.classification_atc_2_id OR
  					t_articles.classification_atc_2_code IS DISTINCT FROM t_classification_atc.classification_atc_2_code OR
  					t_articles.classification_atc_2_texte IS DISTINCT FROM t_classification_atc.classification_atc_2_texte OR
  					t_articles.classification_atc_3_id IS DISTINCT FROM t_classification_atc.classification_atc_3_id OR
  					t_articles.classification_atc_3_code IS DISTINCT FROM t_classification_atc.classification_atc_3_code OR
  					t_articles.classification_atc_3_texte IS DISTINCT FROM t_classification_atc.classification_atc_3_texte OR
  					t_articles.classification_atc_4_id IS DISTINCT FROM t_classification_atc.classification_atc_4_id OR
  					t_articles.classification_atc_4_code IS DISTINCT FROM t_classification_atc.classification_atc_4_code OR
  					t_articles.classification_atc_4_texte IS DISTINCT FROM t_classification_atc.classification_atc_4_texte OR
  					t_articles.unite_stockage_code IS DISTINCT FROM t_unites_stockage.code OR
  					t_articles.unite_stockage_texte IS DISTINCT FROM t_unites_stockage.texte_court OR
  					t_articles.unite_stockage_section_id IS DISTINCT FROM t_unites_stockage.section_id OR
  					t_articles.unite_stockage_section_code IS DISTINCT FROM t_unites_stockage.section_code OR
  					t_articles.unite_stockage_section_texte IS DISTINCT FROM t_unites_stockage.section_texte OR
  					
  					t_articles.unite_distribution_code IS DISTINCT FROM t_unites_distribution.code OR
  					t_articles.unite_distribution_texte IS DISTINCT FROM t_unites_distribution.texte_court OR
  					t_articles.unite_distribution_section_id IS DISTINCT FROM t_unites_distribution.section_id OR
  					t_articles.unite_distribution_section_code IS DISTINCT FROM t_unites_distribution.section_code OR
  					t_articles.unite_distribution_section_texte IS DISTINCT FROM t_unites_distribution.section_texte OR
  					t_articles.compte_code IS DISTINCT FROM t_compte.code OR
  					t_articles.compte_texte IS DISTINCT FROM t_compte.texte_court OR
  					t_articles.compte_section_id IS DISTINCT FROM t_compte.section_id OR
  					t_articles.compte_section_code IS DISTINCT FROM t_compte.section_code OR
  					t_articles.compte_section_texte IS DISTINCT FROM t_compte.section_texte
  				);
  			END IF;
  			
  			IF i_table_code IN ('*ALL', 'TYF') THEN
  				UPDATE eco.t_fournisseurs SET
  					type_code = t_types_fournisseurs.code,
  					type_texte = t_types_fournisseurs.texte_court,
  					type_section_id = t_types_fournisseurs.section_id,
  					type_section_code = t_types_fournisseurs.section_code,
  					type_section_texte = t_types_fournisseurs.section_texte
  				FROM eco.t_types_fournisseurs
  				WHERE type_id = t_types_fournisseurs.oid
  					AND (
  						type_code IS DISTINCT FROM t_types_fournisseurs.code OR
  						type_texte IS DISTINCT FROM t_types_fournisseurs.texte_court OR
  						type_section_id IS DISTINCT FROM t_types_fournisseurs.section_id OR
  						type_section_code IS DISTINCT FROM t_types_fournisseurs.section_code OR
  						type_section_texte IS DISTINCT FROM t_types_fournisseurs.section_texte
  					);
  			END IF;
  	RETURN 'OK';
  END;