<?xml version="1.0" encoding="ISO-8859-1"?>
<ROOT>
	
	
	<NODE name="INIT" label="INITIALISATIONS">
	
		
		
	</NODE>

	<NODE name="PAIE" label="RECUPERATION DES DONNEES DE PAIE">
    
        <NODE label="Chiffrier">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_chiffrier_production 
					WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]])
					', 'temp e_chiffrier_production'
				);
			
				TRUNCATE rh.p_chiffrier_production 
				;

				INSERT INTO rh.p_chiffrier_production(
					entreprise_id, etablissement_id, mois, montant_brut, nombre_heures, 
					nombre_heures_od, nombre_salaries)
				SELECT 
					entreprise_id, etablissement_id, mois, montant_brut, nombre_heures, 
					nombre_heures_od, nombre_salaries
				FROM e_chiffrier_production
                ;

			]]></sqlcmd>
		</NODE>
			
		<NODE label="Salariés">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_salaries
					WHERE oid IN (
								SELECT p_contrats.salarie_id 
								FROM rh.p_contrats_mois 
								JOIN rh.p_contrats ON contrat_id = p_contrats.oid 
								WHERE p_contrats_mois.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR
									p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]])
									) OR
							oid IN (
								SELECT salarie_id FROM rh.p_historique_paie WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]])
								)
					', 'temp e_salaries'
				);
				
				TRUNCATE rh.p_salaries
				;

				INSERT INTO rh.p_salaries(
					code, code_cotisation_id, code_original, code_postal_id, date_anciennete, 
					date_debut, date_entree_ets, date_entree_fp, date_entree_fph, 
					date_fin, date_naissance, date_sortie_ets, entreprise_id, finess, 
					matricule, matricule_retraite, nationalite_id, no_adeli, nom, 
					nom_naissance, oid, personne_id, prenom, profil_id, salarie_fusionne_id, 
					section_code, section_id, section_texte, sexe, situation_famille_id)
				SELECT 
					code, code_cotisation_id, code_original, COALESCE(c_codes_postaux.oid,0) AS code_postal_id, date_anciennete, 
					date_debut, date_entree_ets, date_entree_fp, date_entree_fph, 
					date_fin, date_naissance, date_sortie_ets, entreprise_id, finess, 
					matricule, matricule_retraite, nationalite_id, no_adeli, nom, 
					nom_naissance, e_salaries.oid, personne_id, prenom, profil_id, salarie_fusionne_id, 
					section_code, section_id, section_texte, sexe, situation_famille_id
				FROM e_salaries
				LEFT JOIN c_codes_postaux ON e_salaries.code_postal_id = c_codes_postaux.oid_source
				WHERE e_salaries.oid NOT IN (SELECT oid FROM rh.p_salaries)
				;
				
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_personne
					', 'temp e_personne'
				);
				
				TRUNCATE rh.p_personne
				;

				INSERT INTO rh.p_personne(
					cle_interne, date_naissance, matricule_courant, nom, nom_naissance, 
					oid, prenom, salarie_array_id, salarie_courant_id, sexe)
				SELECT 
					cle_interne, date_naissance, matricule_courant, nom, nom_naissance, 
					oid, prenom, salarie_array_id, salarie_courant_id, sexe
				FROM e_personne
				WHERE oid NOT IN (SELECT oid FROM rh.p_personne)
				;
				
			]]></sqlcmd>
		</NODE>
		
		
		<NODE label="Contrats">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_contrats
					WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR
							oid IN (
								SELECT contrat_id FROM rh.p_historique_paie WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]])
								)
					', 'temp e_contrats'
				);
				
				TRUNCATE rh.p_contrats
				;

				INSERT INTO rh.p_contrats(
					anciennete_anterieure_calculee_jours, anciennete_anterieure_calculee_mois, 
					anciennete_anterieure_jours, anciennete_anterieure_mois, code_original, 
					date_debut, date_fin, etablissement_id, numero_contrat, oid, 
					profil_id, salarie_id, salarie_remplace_id)
				SELECT 
					anciennete_anterieure_calculee_jours, anciennete_anterieure_calculee_mois, 
					anciennete_anterieure_jours, anciennete_anterieure_mois, code_original, 
					date_debut, date_fin, etablissement_id, numero_contrat, oid, 
					profil_id, salarie_id, salarie_remplace_id
				FROM e_contrats
				WHERE oid NOT IN (SELECT oid FROM rh.p_contrats)
				;
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT p_contrats_mois.*
					FROM rh.p_contrats_mois
					JOIN rh.p_contrats ON contrat_id = p_contrats.oid
					WHERE p_contrats_mois.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR
						p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR
							p_contrats_mois.oid IN (
								SELECT contrat_mois_id FROM rh.p_historique_paie WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]])
								)
					', 'temp e_contrats_mois'
				);
				
				TRUNCATE rh.p_contrats_mois
				;

				INSERT INTO rh.p_contrats_mois(
					age_id, age_jours, anciennete_annee_id, anciennete_fp_annee_id, 
					anciennete_fp_mois, anciennete_fph_annee_id, anciennete_fph_mois, 
					anciennete_grade_annee_id, anciennete_grade_mois, anciennete_jours, 
					anciennete_mois, contrat_id, date_debut, date_fin, equivalent_temps_plein, 
					est_hors_periode, etablissement_id, fictif, mois_activite, nombre_debut_contrat, 
					nombre_departs, nombre_entrees, nombre_fin_contrat, nombre_heures, 
					oid, present_debut_mois, present_fin_mois, profil_id, salarie_id)
				SELECT 
					age_id, age_jours, anciennete_annee_id, anciennete_fp_annee_id, 
					anciennete_fp_mois, anciennete_fph_annee_id, anciennete_fph_mois, 
					anciennete_grade_annee_id, anciennete_grade_mois, anciennete_jours, 
					anciennete_mois, contrat_id, date_debut, date_fin, equivalent_temps_plein, 
					est_hors_periode, etablissement_id, fictif, mois_activite, nombre_debut_contrat, 
					nombre_departs, nombre_entrees, nombre_fin_contrat, nombre_heures, 
					oid, present_debut_mois, present_fin_mois, profil_id, salarie_id
				FROM e_contrats_mois
				WHERE oid NOT IN (SELECT oid FROM rh.p_contrats_mois)
				;
				
			]]></sqlcmd>
		</NODE>
		
		
		<NODE label="Paie">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_historique_paie
					WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
					', 'temp e_historique_paie'
				);
				
				TRUNCATE rh.p_historique_paie
				;

				INSERT INTO rh.p_historique_paie(
					age_id, base, compte_id, contrat_id, contrat_mois_id, date_debut, 
					date_fin, date_paie, heure_payee, heure_travaillee, mois_activite, 
					mois_paie, montant_avantage_nature, montant_brut, montant_cotisation_patronale, 
					montant_cotisation_salarie, montant_frais_imposables, montant_masse_salariale, 
					montant_net_a_payer_salarie, montant_net_imposable_salarie, montant_od_net_patronale, 
					montant_od_net_salarie, montant_patronal, montant_salarial, nombre, 
					oid, organisme_cotisation_id, profil_id, rubrique_id, salarie_id, 
					taux_cotisation_patronale, taux_cotisation_salarie, ventilation_1_id, 
					ventilation_2_id, ventilation_3_id, etablissement_id)
				SELECT 
					age_id, base, compte_id, contrat_id, contrat_mois_id, date_debut, 
					date_fin, date_paie, heure_payee, heure_travaillee, mois_activite, 
					mois_paie, montant_avantage_nature, montant_brut, montant_cotisation_patronale, 
					montant_cotisation_salarie, montant_frais_imposables, montant_masse_salariale, 
					montant_net_a_payer_salarie, montant_net_imposable_salarie, montant_od_net_patronale, 
					montant_od_net_salarie, montant_patronal, montant_salarial, nombre, 
					oid, organisme_cotisation_id, profil_id, rubrique_id, salarie_id, 
					taux_cotisation_patronale, taux_cotisation_salarie, ventilation_1_id, 
					ventilation_2_id, ventilation_3_id, etablissement_id
				FROM e_historique_paie
				WHERE oid NOT IN (SELECT oid FROM rh.p_historique_paie)
				;
				
			]]></sqlcmd>
		</NODE>
		
		<NODE label="Ventilation">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_ventilation
					', 'temp e_ventilation'
				);
				
				TRUNCATE rh.p_ventilation
				;

				INSERT INTO rh.p_ventilation(
					code, oid, plan_analytique_id, texte)
				SELECT 
					code, oid, plan_analytique_id, texte
				FROM e_ventilation
				WHERE oid NOT IN (SELECT oid FROM rh.p_ventilation)
				;
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_ventilation_section
					', 'temp e_ventilation_section'
				);
				
				TRUNCATE rh.p_ventilation_section
				;

				INSERT INTO rh.p_ventilation_section(
					ratio, section_analytique_code, section_analytique_id, 
					section_analytique_section_code, section_analytique_section_id, 
					section_analytique_section_texte, section_analytique_texte, ventilation_id)
				SELECT 
					ratio, section_analytique_code, section_analytique_id, 
					section_analytique_section_code, section_analytique_section_id, 
					section_analytique_section_texte, section_analytique_texte, ventilation_id
				FROM e_ventilation_section
				WHERE ventilation_id NOT IN (SELECT ventilation_id FROM rh.p_ventilation_section)
				;
				
			]]></sqlcmd>
		</NODE>
        
		<NODE label="Arrets">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT p_arrets_travail.*
					FROM rh.p_arrets_travail
					JOIn rh.p_contrats ON contrat_id = p_contrats.oid
					WHERE p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
					', 'temp e_arrets_travail'
				);
				
				TRUNCATE rh.p_arrets_travail
				;

				INSERT INTO rh.p_arrets_travail(
					contrat_id, date_debut, date_fin, date_reprise, mois_activite, 
					motif_arret_id, nb_heures, nb_jours, oid, precision_motif_arret_id, 
					salarie_id
					)
				SELECT 
					contrat_id, date_debut, date_fin, date_reprise, mois_activite, 
					motif_arret_id, nb_heures, nb_jours, oid, precision_motif_arret_id, 
					salarie_id
				FROM e_arrets_travail
				;
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT p_arrets_travail_mois.*
					FROM rh.p_arrets_travail_mois
					JOIn rh.p_contrats ON contrat_id = p_contrats.oid
					WHERE p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
					', 'temp e_arrets_travail_mois'
				);
				
				TRUNCATE rh.p_arrets_travail_mois
				;

				INSERT INTO rh.p_arrets_travail_mois(
					arret_travail_id, contrat_id, contrat_mois_id, date_debut, date_fin, 
					mois_activite, nb_arret, nb_debut_arret, nb_fin_arret, nb_heures, 
					nb_jours, nb_reprise_apres_arret, salarie_id)
				SELECT 
					arret_travail_id, contrat_id, contrat_mois_id, date_debut, date_fin, 
					mois_activite, nb_arret, nb_debut_arret, nb_fin_arret, nb_heures, 
					nb_jours, nb_reprise_apres_arret, salarie_id
				FROM e_arrets_travail_mois
				;
				
			]]></sqlcmd>
		</NODE>
		
        
        <NODE label="Arrets">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT p_arrets_travail.*
					FROM rh.p_arrets_travail
					JOIn rh.p_contrats ON contrat_id = p_contrats.oid
					WHERE p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
					', 'temp e_arrets_travail'
				);
				
				TRUNCATE rh.p_arrets_travail
				;

				INSERT INTO rh.p_arrets_travail(
					contrat_id, date_debut, date_fin, date_reprise, mois_activite, 
					motif_arret_id, nb_heures, nb_jours, oid, precision_motif_arret_id, 
					salarie_id
					)
				SELECT 
					contrat_id, date_debut, date_fin, date_reprise, mois_activite, 
					motif_arret_id, nb_heures, nb_jours, oid, precision_motif_arret_id, 
					salarie_id
				FROM e_arrets_travail
				;
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT p_arrets_travail_mois.*
					FROM rh.p_arrets_travail_mois
					JOIn rh.p_contrats ON contrat_id = p_contrats.oid
					WHERE p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
					', 'temp e_arrets_travail_mois'
				);
				
				TRUNCATE rh.p_arrets_travail_mois
				;

				INSERT INTO rh.p_arrets_travail_mois(
					arret_travail_id, contrat_id, contrat_mois_id, date_debut, date_fin, 
					mois_activite, nb_arret, nb_debut_arret, nb_fin_arret, nb_heures, 
					nb_jours, nb_reprise_apres_arret, salarie_id)
				SELECT 
					arret_travail_id, contrat_id, contrat_mois_id, date_debut, date_fin, 
					mois_activite, nb_arret, nb_debut_arret, nb_fin_arret, nb_heures, 
					nb_jours, nb_reprise_apres_arret, salarie_id
				FROM e_arrets_travail_mois
				;
				
			]]></sqlcmd>
		</NODE>
		
		
		<NODE label="Profils">
			<sqlcmd><![CDATA[
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_profils
					', 'temp e_profils'
				);
				
				TRUNCATE rh.p_profils
				;

				INSERT INTO rh.p_profils(
					cadre_emploi_code, cadre_emploi_code_original, cadre_emploi_id, 
					cadre_emploi_section_code, cadre_emploi_section_id, cadre_emploi_section_texte, 
					cadre_emploi_texte, categorie_conge_code, categorie_conge_code_original, 
					categorie_conge_id, categorie_conge_section_code, categorie_conge_section_id, 
					categorie_conge_section_texte, categorie_conge_texte, categorie_socio_professionnelle_code, 
					categorie_socio_professionnelle_code_original, categorie_socio_professionnelle_id, 
					categorie_socio_professionnelle_section_code, categorie_socio_professionnelle_section_id, 
					categorie_socio_professionnelle_section_texte, categorie_socio_professionnelle_texte, 
					categorie_statutaire_code, categorie_statutaire_code_original, 
					categorie_statutaire_id, categorie_statutaire_section_code, categorie_statutaire_section_id, 
					categorie_statutaire_section_texte, categorie_statutaire_texte, 
					code_emploi_code, code_emploi_code_original, code_emploi_id, 
					code_emploi_section_code, code_emploi_section_id, code_emploi_section_texte, 
					code_emploi_texte, commission_paritaire_code, commission_paritaire_code_original, 
					commission_paritaire_id, commission_paritaire_section_code, commission_paritaire_section_id, 
					commission_paritaire_section_texte, commission_paritaire_texte, 
					compte_salarie_code, compte_salarie_code_original, compte_salarie_id, 
					compte_salarie_section_code, compte_salarie_section_id, compte_salarie_section_texte, 
					compte_salarie_texte, filiere_code, filiere_code_original, filiere_id, 
					filiere_section_code, filiere_section_id, filiere_section_texte, 
					filiere_texte, grille_code, grille_code_original, grille_groupe_code, 
					grille_groupe_code_original, grille_groupe_id, grille_groupe_section_code, 
					grille_groupe_section_id, grille_groupe_section_texte, grille_groupe_texte, 
					grille_id, grille_section_code, grille_section_id, grille_section_texte, 
					grille_texte, groupe_cotisant_code, groupe_cotisant_code_original, 
					groupe_cotisant_id, groupe_cotisant_section_code, groupe_cotisant_section_id, 
					groupe_cotisant_section_texte, groupe_cotisant_texte, lettre_budgetaire_code, 
					lettre_budgetaire_code_original, lettre_budgetaire_id, lettre_budgetaire_section_code, 
					lettre_budgetaire_section_id, lettre_budgetaire_section_texte, 
					lettre_budgetaire_texte, motif_debut_code, motif_debut_code_original, 
					motif_debut_id, motif_debut_section_code, motif_debut_section_id, 
					motif_debut_section_texte, motif_debut_texte, motif_fin_code, 
					motif_fin_code_original, motif_fin_id, motif_fin_section_code, 
					motif_fin_section_id, motif_fin_section_texte, motif_fin_texte, 
					oid, qualification_code, qualification_code_original, qualification_id, 
					qualification_section_code, qualification_section_id, qualification_section_texte, 
					qualification_texte, section_analytique_code, section_analytique_code_original, 
					section_analytique_id, section_analytique_paie_code, section_analytique_paie_code_original, 
					section_analytique_paie_id, section_analytique_paie_section_code, 
					section_analytique_paie_section_id, section_analytique_paie_section_texte, 
					section_analytique_paie_texte, section_analytique_section_code, 
					section_analytique_section_id, section_analytique_section_texte, 
					section_analytique_texte, service_code, service_code_original, 
					service_id, service_section_code, service_section_id, service_section_texte, 
					service_texte, societe_interim_code, societe_interim_code_original, 
					societe_interim_id, societe_interim_section_code, societe_interim_section_id, 
					societe_interim_section_texte, societe_interim_texte, specialite_code, 
					specialite_code_original, specialite_id, specialite_section_code, 
					specialite_section_id, specialite_section_texte, specialite_texte, 
					statut_code, statut_code_original, statut_id, statut_section_code, 
					statut_section_id, statut_section_texte, statut_texte, type_contrat_code, 
					type_contrat_code_original, type_contrat_id, type_contrat_section_code, 
					type_contrat_section_id, type_contrat_section_texte, type_contrat_texte, 
					type_horaire_code, type_horaire_code_original, type_horaire_id, 
					type_horaire_section_code, type_horaire_section_id, type_horaire_section_texte, 
					type_horaire_texte, type_temps_travail_code, type_temps_travail_code_original, 
					type_temps_travail_id, type_temps_travail_section_code, type_temps_travail_section_id, 
					type_temps_travail_section_texte, type_temps_travail_texte, unite_fonctionnelle_code, 
					unite_fonctionnelle_code_original, unite_fonctionnelle_id, unite_fonctionnelle_section_code, 
					unite_fonctionnelle_section_id, unite_fonctionnelle_section_texte, 
					unite_fonctionnelle_texte)
				SELECT 
					cadre_emploi_code, cadre_emploi_code_original, cadre_emploi_id, 
					cadre_emploi_section_code, cadre_emploi_section_id, cadre_emploi_section_texte, 
					cadre_emploi_texte, categorie_conge_code, categorie_conge_code_original, 
					categorie_conge_id, categorie_conge_section_code, categorie_conge_section_id, 
					categorie_conge_section_texte, categorie_conge_texte, categorie_socio_professionnelle_code, 
					categorie_socio_professionnelle_code_original, categorie_socio_professionnelle_id, 
					categorie_socio_professionnelle_section_code, categorie_socio_professionnelle_section_id, 
					categorie_socio_professionnelle_section_texte, categorie_socio_professionnelle_texte, 
					categorie_statutaire_code, categorie_statutaire_code_original, 
					categorie_statutaire_id, categorie_statutaire_section_code, categorie_statutaire_section_id, 
					categorie_statutaire_section_texte, categorie_statutaire_texte, 
					code_emploi_code, code_emploi_code_original, code_emploi_id, 
					code_emploi_section_code, code_emploi_section_id, code_emploi_section_texte, 
					code_emploi_texte, commission_paritaire_code, commission_paritaire_code_original, 
					commission_paritaire_id, commission_paritaire_section_code, commission_paritaire_section_id, 
					commission_paritaire_section_texte, commission_paritaire_texte, 
					compte_salarie_code, compte_salarie_code_original, compte_salarie_id, 
					compte_salarie_section_code, compte_salarie_section_id, compte_salarie_section_texte, 
					compte_salarie_texte, filiere_code, filiere_code_original, filiere_id, 
					filiere_section_code, filiere_section_id, filiere_section_texte, 
					filiere_texte, grille_code, grille_code_original, grille_groupe_code, 
					grille_groupe_code_original, grille_groupe_id, grille_groupe_section_code, 
					grille_groupe_section_id, grille_groupe_section_texte, grille_groupe_texte, 
					grille_id, grille_section_code, grille_section_id, grille_section_texte, 
					grille_texte, groupe_cotisant_code, groupe_cotisant_code_original, 
					groupe_cotisant_id, groupe_cotisant_section_code, groupe_cotisant_section_id, 
					groupe_cotisant_section_texte, groupe_cotisant_texte, lettre_budgetaire_code, 
					lettre_budgetaire_code_original, lettre_budgetaire_id, lettre_budgetaire_section_code, 
					lettre_budgetaire_section_id, lettre_budgetaire_section_texte, 
					lettre_budgetaire_texte, motif_debut_code, motif_debut_code_original, 
					motif_debut_id, motif_debut_section_code, motif_debut_section_id, 
					motif_debut_section_texte, motif_debut_texte, motif_fin_code, 
					motif_fin_code_original, motif_fin_id, motif_fin_section_code, 
					motif_fin_section_id, motif_fin_section_texte, motif_fin_texte, 
					oid, qualification_code, qualification_code_original, qualification_id, 
					qualification_section_code, qualification_section_id, qualification_section_texte, 
					qualification_texte, section_analytique_code, section_analytique_code_original, 
					section_analytique_id, section_analytique_paie_code, section_analytique_paie_code_original, 
					section_analytique_paie_id, section_analytique_paie_section_code, 
					section_analytique_paie_section_id, section_analytique_paie_section_texte, 
					section_analytique_paie_texte, section_analytique_section_code, 
					section_analytique_section_id, section_analytique_section_texte, 
					section_analytique_texte, service_code, service_code_original, 
					service_id, service_section_code, service_section_id, service_section_texte, 
					service_texte, societe_interim_code, societe_interim_code_original, 
					societe_interim_id, societe_interim_section_code, societe_interim_section_id, 
					societe_interim_section_texte, societe_interim_texte, specialite_code, 
					specialite_code_original, specialite_id, specialite_section_code, 
					specialite_section_id, specialite_section_texte, specialite_texte, 
					statut_code, statut_code_original, statut_id, statut_section_code, 
					statut_section_id, statut_section_texte, statut_texte, type_contrat_code, 
					type_contrat_code_original, type_contrat_id, type_contrat_section_code, 
					type_contrat_section_id, type_contrat_section_texte, type_contrat_texte, 
					type_horaire_code, type_horaire_code_original, type_horaire_id, 
					type_horaire_section_code, type_horaire_section_id, type_horaire_section_texte, 
					type_horaire_texte, type_temps_travail_code, type_temps_travail_code_original, 
					type_temps_travail_id, type_temps_travail_section_code, type_temps_travail_section_id, 
					type_temps_travail_section_texte, type_temps_travail_texte, unite_fonctionnelle_code, 
					unite_fonctionnelle_code_original, unite_fonctionnelle_id, unite_fonctionnelle_section_code, 
					unite_fonctionnelle_section_id, unite_fonctionnelle_section_texte, 
					unite_fonctionnelle_texte
				FROM e_profils
				WHERE oid NOT IN (SELECT oid FROM rh.p_profils)
				;
				
				
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.p_profil_contrat_mois
					WHERE contrat_mois_id IN (
						SELECT p_contrats_mois.oid 
						FROM rh.p_contrats_mois 
						JOIN rh.p_contrats ON contrat_id = p_contrats.oid 
						WHERE p_contrats_mois.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR
							p_contrats.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
							) OR
						contrat_mois_id IN (
							SELECT contrat_mois_id 
							FROM rh.p_historique_paie 
							WHERE etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]])
							)
							
					', 'temp e_profil_contrat_mois'
				);
				
				TRUNCATE rh.p_profil_contrat_mois
				;

				INSERT INTO rh.p_profil_contrat_mois(
					contrat_mois_id, mois, oid, profil_avant_transformation_id, profil_id, 
					ratio, salarie_id, pole_id)
				SELECT 
					contrat_mois_id, mois, oid, profil_avant_transformation_id, profil_id, 
					ratio, salarie_id, pole_id
				FROM e_profil_contrat_mois
				WHERE oid NOT IN (SELECT oid FROM rh.p_profil_contrat_mois)
				;
				
				-- Ménage dans les profils récupérés
				DELETE
				FROM rh.p_profils
				WHERE
					oid NOT IN (SELECT profil_id FROM rh.p_profil_contrat_mois) AND
					oid NOT IN (SELECT profil_id FROM rh.p_salaries) AND
					oid NOT IN (SELECT profil_avant_transformation_id FROM rh.p_profil_contrat_mois WHERE profil_avant_transformation_id IS NOT NULL) AND
					oid NOT IN (SELECT profil_id FROM rh.p_contrats)  
				;
				
			]]></sqlcmd>
		</NODE>
		
		<NODE label="Planning">
			<sqlcmd><![CDATA[

				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT p_planning_mouvement.*
					FROM rh.p_planning_mouvement
					JOIN rh.p_contrats_mois ON p_planning_mouvement.contrat_mois_id = p_contrats_mois.oid
					WHERE p_contrats_mois.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) 
					', 'temp e_planning_mouvement'
				);
				
				TRUNCATE rh.p_planning_mouvement
				;

				INSERT INTO rh.p_planning_mouvement(
				    contrat_id, 
					contrat_mois_id, 
					date, 
					etablissement_id, 
					mois, 
					niveau_id, 
				    qualification_id, 
					salarie_id, 
					semaine, 
					service_id, 
					temps_absence, 
					temps_absence_ajuste, 
				    temps_du, 
				    temps_du_ajuste, 
					temps_du_initial, 
					temps_valide, 
					temps_valide_ajuste,
					temps_presence,
					temps_presence_ajuste, 
					type_absence_id, 
					code_horaire_id
					)
				SELECT 
				    contrat_id, 
					contrat_mois_id, 
					date, 
					etablissement_id, 
					mois, 
					niveau_id, 
				    qualification_id, 
					salarie_id, 
					semaine, 
					service_id, 
					temps_absence, 
					temps_absence_ajuste, 
				    temps_du, 
				    temps_du_ajuste, 
					temps_du_initial, 
					temps_valide, 
					temps_valide_ajuste,
					temps_presence,
					temps_presence_ajuste, 
					type_absence_id, 
					code_horaire_id
				FROM e_planning_mouvement
				;
				
			]]></sqlcmd>
		</NODE>
		
		
	</NODE>
	
	<NODE name="POST" label="TRAITEMENTS COMPLEMENTAIRES">
		<NODE label="Séquences">
			<sqlcmd><![CDATA[

				SELECT base.cti_verify_sequences('rh');
		
			]]></sqlcmd>
		</NODE>	
		
		<NODE label="Référencement Paramètres">
			<sqlcmd><![CDATA[

		
			SELECT rh.cti_reorganize_profils()
			;
			
			/* OIDS */
			-- Màj de la table p_oids
			TRUNCATE rh.p_oids
			;
			
			SELECT base.cti_stash_table_constraints('rh', 'p_oids')
			;
			
			SELECT base.cti_stash_table_indexes('rh', 'p_oids')
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'ages', age_id
				FROM rh.p_contrats_mois
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'anciennetes_annee', anciennete_annee_id
				FROM rh.p_contrats_mois
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'salaries', salarie_id
				FROM rh.p_contrats_mois
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'services', service_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'qualifications', qualification_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'types_temps_travail', type_temps_travail_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'types_contrat', type_contrat_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'specialites', specialite_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'categories_socio_professionnelle', categorie_socio_professionnelle_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'statuts', statut_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'codes_emploi', code_emploi_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'motifs_debut_contrat', motif_debut_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'motifs_fin_contrat', motif_fin_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'situations_famille', situation_famille_id
				FROM rh.p_salaries
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'nationalites', nationalite_id
				FROM rh.p_salaries
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'codes_postaux', code_postal_id
				FROM rh.p_salaries
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'departements', departement_id
				FROM rh.p_salaries 
					JOIN rh.t_codes_postaux ON (code_postal_id = t_codes_postaux.oid)
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'sections_analytiques_paie', section_analytique_paie_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'sections_analytiques', section_analytique_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'section_analytique', section_analytique_id
				FROM rh.p_ventilation_section
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'grilles', grille_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'grilles_groupes', grille_groupe_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'groupes_cotisant', groupe_cotisant_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'societes_interim', societe_interim_id
				FROM rh.p_profils
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'motifs_arret', motif_arret_id
				FROM rh.p_arrets_travail
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'precisions_motif_arret', precision_motif_arret_id
				FROM rh.p_arrets_travail
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'rubriques', rubrique_id
				FROM rh.p_historique_paie
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'organismes_cotisation', organisme_cotisation_id
				FROM rh.p_historique_paie
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'motifs_visite', motif_visite_id
				FROM rh.p_visites_medicales
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'accident_circonstance', accident_circonstance_id
				FROM rh.p_accident_travail
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'accident_lieu', accident_lieu_id
				FROM rh.p_accident_travail
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'accident_nature', accident_nature_id
				FROM rh.p_accident_travail
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'accident_siege', accident_siege_id
				FROM rh.p_accident_travail
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
				SELECT 'formations', formation_id
				FROM rh.p_formations
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'lettre_budgetaire', lettre_budgetaire_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'compte_salarie', compte_salarie_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'compte', compte_id
                FROM rh.p_historique_paie
				GROUP BY 1,2
			;

			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'categorie_conge', categorie_conge_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'commission_paritaire', commission_paritaire_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'filiere', filiere_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'cadre_emploi', cadre_emploi_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'categorie_statutaire', categorie_statutaire_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'unite_fonctionnelle', unite_fonctionnelle_id
                FROM rh.p_profils
				GROUP BY 1,2
			;
			
			-- Recensement des oid utilisés.
            INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'planning_service', service_id
                FROM rh.p_planning_mouvement
                WHERE service_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_service')
                GROUP BY 1,2
            ;

            INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'planning_qualification', qualification_id
                FROM rh.p_planning_mouvement
                WHERE qualification_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_qualification')
                GROUP BY 1,2
            ;

            INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'planning_niveau', niveau_id
                FROM rh.p_planning_mouvement
                WHERE niveau_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_niveau')
                GROUP BY 1,2
            ;

            INSERT INTO rh.p_oids (code_table, oid)
                SELECT 'planning_type_absence', type_absence_id
                FROM rh.p_planning_mouvement
                WHERE type_absence_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_type_absence')
                GROUP BY 1,2
            ;
			
			 INSERT INTO rh.p_oids (code_table, oid)
               SELECT 'planning_code_horaire', code_horaire_id
                FROM rh.p_planning_mouvement
                WHERE code_horaire_id NOT IN (SELECT oid FROM rh.p_oids WHERE code_table = 'planning_code_horaire')
                GROUP BY 1,2
            ;
			
			SELECT base.cti_stash_pop_table_constraints('rh', 'p_oids')
			;
			
			SELECT base.cti_stash_pop_table_indexes('rh', 'p_oids')
			;
			
			/* CLASSES */
			-- Màj des classes
			SELECT rh.cti_update_schema_classes('*ALL')
			;
			
			]]></sqlcmd>
		</NODE>
	</NODE>
	<NODE name="VACUUM">
		<NODE label="Réorganisation tables">
			<sqlcmd><![CDATA[
			
			SELECT base.cti_vacuum('rh.p_accident_travail');
			SELECT base.cti_vacuum('rh.p_arrets_travail');
			SELECT base.cti_vacuum('rh.p_arrets_travail_mois');
			SELECT base.cti_vacuum('rh.p_chiffrier_production');
			SELECT base.cti_vacuum('rh.p_contrats');
			SELECT base.cti_vacuum('rh.p_contrats_mois');
			SELECT base.cti_vacuum('rh.p_formations');
			SELECT base.cti_vacuum('rh.p_handicap');
			SELECT base.cti_vacuum('rh.p_historique_paie');
			SELECT base.cti_vacuum('rh.p_oids');
			SELECT base.cti_vacuum('rh.p_planning_mouvement');
			SELECT base.cti_vacuum('rh.p_profil_contrat_mois');
			SELECT base.cti_vacuum('rh.p_profils');
			SELECT base.cti_vacuum('rh.p_salaries');
			SELECT base.cti_vacuum('rh.p_ventilation');
			SELECT base.cti_vacuum('rh.p_ventilation_section');
			SELECT base.cti_vacuum('rh.p_visites_medicales');
			SELECT base.cti_vacuum('rh.t_accident_circonstance');
			SELECT base.cti_vacuum('rh.t_accident_lieu');
			SELECT base.cti_vacuum('rh.t_accident_nature');
			SELECT base.cti_vacuum('rh.t_accident_siege');
			SELECT base.cti_vacuum('rh.t_cadre_emploi');
			SELECT base.cti_vacuum('rh.t_categorie_conge');
			SELECT base.cti_vacuum('rh.t_categorie_statutaire');
			SELECT base.cti_vacuum('rh.t_categories_socio_professionnelle');
			SELECT base.cti_vacuum('rh.t_codes_emploi');
			SELECT base.cti_vacuum('rh.t_codes_postaux');
			SELECT base.cti_vacuum('rh.t_commission_paritaire');
			SELECT base.cti_vacuum('rh.t_compte');
			SELECT base.cti_vacuum('rh.t_departements');
			SELECT base.cti_vacuum('rh.t_entreprises');
			SELECT base.cti_vacuum('rh.t_etablissements');
			SELECT base.cti_vacuum('rh.t_filiere');
			SELECT base.cti_vacuum('rh.t_grilles');
			SELECT base.cti_vacuum('rh.t_grilles_groupes');
			SELECT base.cti_vacuum('rh.t_groupes_cotisant');
			SELECT base.cti_vacuum('rh.t_lettre_budgetaire');
			SELECT base.cti_vacuum('rh.t_liste_formations');
			SELECT base.cti_vacuum('rh.t_motifs_arret');
			SELECT base.cti_vacuum('rh.t_motifs_debut_contrat');
			SELECT base.cti_vacuum('rh.t_motifs_fin_contrat');
			SELECT base.cti_vacuum('rh.t_motifs_visite');
			SELECT base.cti_vacuum('rh.t_nationalites');
			SELECT base.cti_vacuum('rh.t_organismes_cotisation');
			SELECT base.cti_vacuum('rh.t_precisions_motif_arret');
			SELECT base.cti_vacuum('rh.t_qualifications');
			SELECT base.cti_vacuum('rh.t_rapports');
			SELECT base.cti_vacuum('rh.t_rapports_rubriques');
			SELECT base.cti_vacuum('rh.t_rubriques');
			SELECT base.cti_vacuum('rh.t_sections_analytiques');
			SELECT base.cti_vacuum('rh.t_sections_analytiques_paie');
			SELECT base.cti_vacuum('rh.t_services');
			SELECT base.cti_vacuum('rh.t_situations_famille');
			SELECT base.cti_vacuum('rh.t_societes_interim');
			SELECT base.cti_vacuum('rh.t_specialites');
			SELECT base.cti_vacuum('rh.t_statuts');
			SELECT base.cti_vacuum('rh.t_types_contrat');
			SELECT base.cti_vacuum('rh.t_types_horaire');
			SELECT base.cti_vacuum('rh.t_types_temps_travail');
			SELECT base.cti_vacuum('rh.t_unite_fonctionnelle');
				
			]]></sqlcmd>
		</NODE>
	</NODE>	

	
	<NODE name="PARAM" label="RECUPERATION DES PARAMETRES">
	
		<NODE label="Initialisations">
			<sqlcmd><![CDATA[

			
			-- Màj des Entreprises
			INSERT INTO rh.t_entreprises(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_entreprises)
			;
			
			-- Màj des Etablissements
			INSERT INTO rh.t_etablissements(oid, code_original, code, texte, texte_court, entreprise_id)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R', 0
				WHERE 0 NOT IN (SELECT oid FROM rh.t_etablissements)
			;
			
			-- Màj des "Catégories socio-professionnelles".
			INSERT INTO rh.t_categories_socio_professionnelle(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_categories_socio_professionnelle)
			;
			
			-- Màj des "Groupes de cotisants".
			INSERT INTO rh.t_groupes_cotisant(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_groupes_cotisant)
			;
			
			-- Màj des motifs de début de contrat.
			INSERT INTO rh.t_motifs_debut_contrat(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_debut_contrat)
			;
			
			-- Màj des motifs de fin de contrat.
			INSERT INTO rh.t_motifs_fin_contrat(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_fin_contrat)
			;
			
			-- Màj des "Nationalités".
			INSERT INTO rh.t_nationalites(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_nationalites)
			;
			
			-- Màj des "Organismes de cotisation".
			INSERT INTO rh.t_organismes_cotisation(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_organismes_cotisation)
			;
			
			-- Màj des "Unités Fonctionnelles".
			INSERT INTO rh.t_unite_fonctionnelle(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_unite_fonctionnelle)
			;
			
			-- Màj des "Rubriques".
			INSERT INTO rh.t_rubriques(oid, code_original, code, texte, texte_court, rang_edition)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R', 0
				WHERE 0 NOT IN (SELECT oid FROM rh.t_rubriques)
			;
			
			-- (création des rubriques CTI de cumul).
			INSERT INTO rh.t_rubriques(code, texte, texte_court, code_original, rang_edition)
				SELECT 'C000', 'Ecart cumulé', 'Ecart cumulé', 'C000', -1
				WHERE 'C000' NOT IN (SELECT code_original FROM rh.t_rubriques)
			;
			
			-- Màj des situations de famille.
			INSERT INTO rh.t_situations_famille(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_situations_famille)
			;
			
			-- Màj des "Types de contrat".
			INSERT INTO rh.t_types_contrat(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_types_contrat)
			;
			
			-- Màj des "Statuts".
			INSERT INTO rh.t_statuts(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_statuts)
			;
			
			-- Màj des types de temps de travail.
			INSERT INTO rh.t_types_temps_travail(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_types_temps_travail)
			;
			
			-- Màj des "Services".
			INSERT INTO rh.t_services(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_services)
			;
			
			-- Màj des "Qualifications".
			INSERT INTO rh.t_qualifications(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_qualifications)
			;

			-- Màj des "Spécialités".
			INSERT INTO rh.t_specialites(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_specialites)
			;
			
			-- Màj des "Lettres Budgétaires".
			INSERT INTO rh.t_lettre_budgetaire(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_lettre_budgetaire)
			;
			
			-- Màj des "Codes emploi".
			INSERT INTO rh.t_codes_emploi(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_codes_emploi)
			;
			
			-- Màj des types d'horaire.
			INSERT INTO rh.t_types_horaire(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_types_horaire)
			;
			
			-- Màj des "Groupes de commission paritaire".
			INSERT INTO rh.t_commission_paritaire(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_commission_paritaire)
			;
			
			-- Màj des grilles.
			INSERT INTO rh.t_grilles(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_grilles)
			;
			
			-- Màj des groupes de grilles.
			INSERT INTO rh.t_grilles_groupes(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_grilles_groupes)
			;
			
			-- Màj des motifs d'arret.
			INSERT INTO rh.t_motifs_arret(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_arret)
			;
			
			-- Màj des précisions du motif d'arrêt.
			INSERT INTO rh.t_precisions_motif_arret(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_precisions_motif_arret)
			;
			
			-- Màj des "Motifs de visite médicale".
			INSERT INTO rh.t_motifs_visite(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_motifs_visite)
			;
			
			-- Màj des "Circonstances d'accident du travail".
			INSERT INTO rh.t_accident_circonstance(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_circonstance)
			;
			
			-- Màj des "Lieux d'accident du travail".
			INSERT INTO rh.t_accident_lieu(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_lieu)
			;
			
			-- Màj de la nature de l'accident du travail.
			INSERT INTO rh.t_accident_nature(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_nature)
			;
			
			-- Màj des sièges d'accident du travail.
			INSERT INTO rh.t_accident_siege(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_accident_siege)
			;

			-- Màj des listes de formations.
			INSERT INTO rh.t_liste_formations(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_liste_formations)
			;
			
			-- Màj des comptes.
			INSERT INTO rh.t_compte(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_compte)
			;
			
			-- Màj des "Catégories de congé".
			INSERT INTO rh.t_categorie_conge(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_categorie_conge)
			;
			
			-- Màj des "Cadres d'emploi".
			INSERT INTO rh.t_cadre_emploi(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_cadre_emploi)
			;
			
			-- Màj des "Filières".
			INSERT INTO rh.t_filiere(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_filiere)
			;
			
			-- Màj des "Catégories statutaires".
			INSERT INTO rh.t_categorie_statutaire(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_categorie_statutaire)
			;
			
			-- Màj des "Codes cotisation".
			INSERT INTO rh.t_code_cotisation(oid, code_original, code, texte, texte_court)
				SELECT 0, '', chr(1) || '*', 'Non renseigné', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_code_cotisation)
			;
			
			-- Sections analytiques niveau 1
			INSERT INTO rh.t_sections_analytiques_paie(oid, code_original, code, texte, texte_court) 
				SELECT 0, '', chr(127) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_sections_analytiques_paie)
			;
			
			INSERT INTO rh.t_sections_analytiques(oid, code_original, code, texte, texte_court) 
				SELECT 0, '', chr(127) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_sections_analytiques)
			;

			INSERT INTO rh.t_section_analytique(oid, code_original, code, texte, texte_court) 
				SELECT 0, '', chr(127) || '*', 'Non renseignée', 'N/R'
				WHERE 0 NOT IN (SELECT oid FROM rh.t_section_analytique)
			;

            INSERT INTO rh.t_planning_type_absence(oid, code_original, code, texte, texte_court)
                SELECT 0, '', chr(1)||'*', 'Non renseigné', 'Non renseigné'
                WHERE 0 NOT IN (SELECT oid FROM rh.t_planning_type_absence)
            ;

			INSERT INTO rh.t_planning_code_horaire(oid, code_original, code, texte, texte_court)
                SELECT 0, '', chr(1)||'*', 'Non renseigné', 'Non renseigné'
                WHERE 0 NOT IN (SELECT oid FROM rh.t_planning_code_horaire)
            ;
			
            INSERT INTO rh.t_planning_qualification(oid, code_original, code, texte, texte_court)
                SELECT 0, '', chr(1)||'*', 'Non renseignée', 'Non renseignée'
                WHERE 0 NOT IN (SELECT oid FROM rh.t_planning_qualification)
            ;

            INSERT INTO rh.t_planning_service(oid, code_original, code, texte, texte_court)
                SELECT 0, '', chr(1)||'*', 'Non renseigné', 'Non renseigné'
                WHERE 0 NOT IN (SELECT oid FROM rh.t_planning_service)
            ;
			
            INSERT INTO rh.t_plan_analytique(oid, code, texte)
				SELECT valeur::bigint, 'VENTANA', 'Ventilation analytique' 
				FROM rh.t_divers 
				WHERE code = 'PAIE_VENTILATION'
				AND 'VENTANA' NOT IN (SELECT code FROM rh.t_plan_analytique)
			
            ;
			
			]]></sqlcmd>
		</NODE>		
			
		<NODE label="Etablissements">
			<sqlcmd><![CDATA[

				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_etablissements
					WHERE code = ANY (string_to_array(''[ETAB]'','' '')) OR oid = 0
					', 'temp e_etablissements'
				);
				
				TRUNCATE rh.t_etablissements
				;

				INSERT INTO rh.t_etablissements(
					base_calcul_etp, code, code_original, entreprise_id, mode_calcul_etp_paye, 
					oid, planning_code, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					base_calcul_etp, code, code_original, entreprise_id, mode_calcul_etp_paye, 
					oid, planning_code, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_etablissements
				WHERE oid NOT IN (SELECT oid FROM rh.t_etablissements)
				;
				
				
				CTISELECT_PROPERTY_READ 'ETABLISSEMENTS_CHOISIS', COALESCE(base.cti_group_concat(oid::text),'0')
				FROM e_etablissements
				;
				
				-- Etablissements dans la paie avec congtrat dans autre
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_etablissements
					WHERE oid IN (
						SELECT p_contrats_mois.etablissement_id
						FROM rh.p_historique_paie
						JOIN rh.p_contrats_mois ON contrat_mois_id = p_contrats_mois.oid
						WHERE p_historique_paie.etablissement_id = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) AND
							p_contrats_mois.etablissement_id <> ALL (Array[[ETABLISSEMENTS_CHOISIS]])
							)
					', 'temp e_etablissements'
				);
				
				INSERT INTO rh.t_etablissements(
					base_calcul_etp, code, code_original, entreprise_id, mode_calcul_etp_paye, 
					oid, planning_code, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					base_calcul_etp, code, code_original, entreprise_id, mode_calcul_etp_paye, 
					oid, planning_code, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_etablissements
				WHERE oid NOT IN (SELECT oid FROM rh.t_etablissements)
				;
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_entreprises
					WHERE oid IN 
						(SELECT entreprise_id
						FROM rh.t_etablissements
						WHERE t_etablissements.oid = ANY (Array[[ETABLISSEMENTS_CHOISIS]]) OR oid = 0
						) OR oid = 0
					', 'temp e_entreprises'
				);
				
				TRUNCATE rh.t_entreprises
				;

				INSERT INTO rh.t_entreprises(
					code, code_original, oid, planning_code, section_code, section_id, 
					section_texte, texte, texte_court)
				SELECT 
					code, code_original, oid, planning_code, section_code, section_id, 
					section_texte, texte, texte_court
				FROM e_entreprises
				WHERE oid NOT IN (SELECT oid FROM rh.t_entreprises)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Catégories">
			<sqlcmd><![CDATA[
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_categories_socio_professionnelle
					', 'temp e_categories_socio_professionnelles'
				);
				
				TRUNCATE rh.t_categories_socio_professionnelle
				;

				INSERT INTO rh.t_categories_socio_professionnelle(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_categories_socio_professionnelles
				WHERE oid NOT IN (SELECT oid FROM rh.t_categories_socio_professionnelle)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Codes postaux">
			<sqlcmd><![CDATA[	
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM base.t_departements
					', 'temp e_departements'
				);

				INSERT INTO base.t_departements(
					code, texte, texte_court)
				SELECT 
					code, texte, texte_court
				FROM e_departements
				WHERE code NOT IN (SELECT code FROM base.t_departements WHERE code IS NOT NULL)
				;
				
				DROP TABLE IF EXISTS c_departements;
				CREATE TEMP TABLE c_departements AS
				SELECT 
					e_departements.oid AS oid_source,
					coalesce(t_departements.oid,0) AS oid
				FROM e_departements
					LEFT JOIN base.t_departements ON e_departements.code = t_departements.code;
				
				CREATE INDEX c_departements_1
				  ON c_departements
				  USING btree
				  (oid_source);

				  
				  
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM base.t_codes_postaux
					', 'temp e_codes_postaux'
				);
				

				INSERT INTO base.t_codes_postaux(
					code, code_geographique_pmsi_population, departement_code, departement_id, 
					departement_texte, latitude, longitude, section_code, section_id, 
					section_texte, texte, texte_court)
				SELECT 
					code, code_geographique_pmsi_population, departement_code, COALESCE(c_departements.oid,0) AS departement_id, 
					departement_texte, latitude, longitude, section_code, section_id, 
					section_texte, texte, texte_court
				FROM e_codes_postaux
				LEFT JOIN c_departements ON e_codes_postaux.departement_id = c_departements.oid_source
				WHERE code NOT IN (SELECT code FROM base.t_codes_postaux WHERE code IS NOT NULL)
				;
				
				DROP TABLE IF EXISTS c_codes_postaux;
				CREATE TEMP TABLE c_codes_postaux AS
				SELECT 
					e_codes_postaux.oid AS oid_source,
					coalesce(t_codes_postaux.oid,0) AS oid
				FROM e_codes_postaux
					LEFT JOIN base.t_codes_postaux ON e_codes_postaux.code = t_codes_postaux.code;
				
				CREATE INDEX c_codes_postaux_1
				  ON c_codes_postaux
				  USING btree
				  (oid_source);
				  
				  
				-- Màj des codes postaux.
				INSERT INTO rh.t_codes_postaux(oid, code, texte, texte_court, longitude, latitude, departement_id, departement_code, departement_texte)
					SELECT
						t_codes_postaux.oid,
						t_codes_postaux.code,
						t_codes_postaux.texte,
						t_codes_postaux.texte_court,
						t_codes_postaux.longitude,
						t_codes_postaux.latitude,
						t_codes_postaux.departement_id,
						t_codes_postaux.departement_code,
						t_codes_postaux.departement_texte
					FROM base.t_codes_postaux
						LEFT JOIN rh.t_codes_postaux t_codes_postaux_rh ON t_codes_postaux_rh.oid = t_codes_postaux.oid
					WHERE t_codes_postaux_rh.oid IS NULL
				;

				UPDATE rh.t_codes_postaux t_codes_postaux_rh
				SET
					code = t_codes_postaux.code,
					texte = t_codes_postaux.texte,
					texte_court = t_codes_postaux.texte_court,
					longitude = t_codes_postaux.longitude,
					latitude = t_codes_postaux.latitude,
					departement_id = t_codes_postaux.departement_id,
					departement_code = t_codes_postaux.departement_code,
					departement_texte = t_codes_postaux.departement_texte
				FROM base.t_codes_postaux
				WHERE 1=1
					AND t_codes_postaux_rh.oid = t_codes_postaux.oid
					AND (1!=1
						OR t_codes_postaux_rh.code IS DISTINCT FROM t_codes_postaux.code
						OR t_codes_postaux_rh.texte IS DISTINCT FROM t_codes_postaux.texte
						OR t_codes_postaux_rh.texte_court IS DISTINCT FROM t_codes_postaux.texte_court
						OR t_codes_postaux_rh.longitude IS DISTINCT FROM t_codes_postaux.longitude
						OR t_codes_postaux_rh.latitude IS DISTINCT FROM t_codes_postaux.latitude
						OR t_codes_postaux_rh.departement_id IS DISTINCT FROM t_codes_postaux.departement_id
						OR t_codes_postaux_rh.departement_code IS DISTINCT FROM t_codes_postaux.departement_code
						OR t_codes_postaux_rh.departement_texte IS DISTINCT FROM t_codes_postaux.departement_texte)
				;

				-- Màj des Depts.
				INSERT INTO rh.t_departements(oid, code, texte, texte_court)
					SELECT
						t_departements.oid,
						t_departements.code,
						t_departements.texte,
						t_departements.texte_court
					FROM base.t_departements
						LEFT JOIN rh.t_departements t_departements_rh ON t_departements_rh.oid = t_departements.oid
					WHERE t_departements_rh.oid IS NULL
				;

				UPDATE rh.t_departements t_departements_rh
				SET
					code = t_departements.code,
					texte = t_departements.texte,
					texte_court = t_departements.texte_court
				FROM base.t_departements
				WHERE
					t_departements_rh.oid = t_departements.oid
					AND (
						t_departements_rh.code IS DISTINCT FROM t_departements.code OR
						t_departements_rh.texte IS DISTINCT FROM t_departements.texte OR
						t_departements_rh.texte_court IS DISTINCT FROM t_departements.texte_court
						)
				;
				
				
			
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Comptes">
			<sqlcmd><![CDATA[			
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_compte
					', 'temp e_compte'
				);
				
				TRUNCATE rh.t_compte
				;

				INSERT INTO rh.t_compte(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_compte
				WHERE oid NOT IN (SELECT oid FROM rh.t_compte)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Divers">
			<sqlcmd><![CDATA[			
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_divers
					', 'temp e_divers'
				);
				
				TRUNCATE rh.t_divers
				;

				INSERT INTO rh.t_divers(
					code, description, show_info_module, texte, valeur, valeur_date)
				SELECT 
					code, description, show_info_module, texte, valeur, valeur_date
				FROM e_divers
				WHERE code NOT IN (SELECT code FROM rh.t_divers)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Grilles">
			<sqlcmd><![CDATA[			
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_grilles
					', 'temp e_grilles'
				);
				
				TRUNCATE rh.t_grilles
				;

				INSERT INTO rh.t_grilles(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_grilles
				WHERE oid NOT IN (SELECT oid FROM rh.t_grilles)
				;
				
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_grilles_groupes
					', 'temp e_grilles_groupes'
				);
				
				TRUNCATE rh.t_grilles_groupes
				;

				INSERT INTO rh.t_grilles_groupes(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_grilles_groupes
				WHERE oid NOT IN (SELECT oid FROM rh.t_grilles_groupes)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Motifs arret">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_motifs_arret
					', 'temp e_motifs_arret'
				);
				
				TRUNCATE rh.t_motifs_arret
				;

				INSERT INTO rh.t_motifs_arret(
					code, code_original, oid, rang_edition, section_code, section_id, 
					section_texte, texte, texte_court)
				SELECT 
					code, code_original, oid, rang_edition, section_code, section_id, 
					section_texte, texte, texte_court
				FROM e_motifs_arret
				WHERE oid NOT IN (SELECT oid FROM rh.t_motifs_arret)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Motifs début et fin">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_motifs_debut_contrat
					', 'temp e_motifs_debut_contrat'
				);

				TRUNCATE rh.t_motifs_debut_contrat
				;

				INSERT INTO rh.t_motifs_debut_contrat(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_motifs_debut_contrat
				WHERE oid NOT IN (SELECT oid FROM rh.t_motifs_debut_contrat)
				;
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_motifs_fin_contrat
					', 'temp e_motifs_fin_contrat'
				);
				
				TRUNCATE rh.t_motifs_fin_contrat
				;

				INSERT INTO rh.t_motifs_fin_contrat(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_motifs_fin_contrat
				WHERE oid NOT IN (SELECT oid FROM rh.t_motifs_fin_contrat)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Nationalités">
			<sqlcmd><![CDATA[	
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_nationalites
					', 'temp e_nationalites'
				);
				
				TRUNCATE rh.t_nationalites
				;

				INSERT INTO rh.t_nationalites(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_nationalites
				WHERE oid NOT IN (SELECT oid FROM rh.t_nationalites)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Qualifications">
			<sqlcmd><![CDATA[		
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_qualifications
					', 'temp e_qualifications'
				);
				
				TRUNCATE rh.t_qualifications
				;

				INSERT INTO rh.t_qualifications(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_qualifications
				WHERE oid NOT IN (SELECT oid FROM rh.t_qualifications)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Rubriques">
			<sqlcmd><![CDATA[		
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_rubriques
					', 'temp e_rubriques'
				);
				
				TRUNCATE rh.t_rubriques
				;

				INSERT INTO rh.t_rubriques(
					c_avantage_nature, c_base, c_brut, c_cotisation_patronale, c_cotisation_salarie, 
					c_frais_imposables, c_heures_payees, c_heures_travaillees, c_masse_salariale, 
					c_net_a_payer, c_net_imposable, c_nombre, c_od_net_patronale, 
					c_od_net_salarie, chapitre_bulletin, code, code_calcul, code_original, 
					coefficient, coefficient_base, coefficient_nombre, coefficient_txp, 
					coefficient_txs, heures_payees, oid, p_avantage_nature, p_base, 
					p_brut, p_cotisation_patronale, p_cotisation_salarie, p_cumul, 
					p_detail, p_frais_imposables, p_heures_payees, p_heures_travaillees, 
					p_masse_salariale, p_net_a_payer, p_net_imposable, p_nombre, 
					p_od_net_patronale, p_od_net_salarie, rang_edition, s_avantage_nature, 
					s_base, s_brut, s_cotisation_patronale, s_cotisation_salarie, 
					s_frais_imposables, s_heures_payees, s_heures_travaillees, s_masse_salariale, 
					s_net_a_payer, s_net_imposable, s_nombre, s_od_net_patronale, 
					s_od_net_salarie, section_code, section_id, section_texte, texte, 
					texte_court, unite, user_modified)
				SELECT 
					c_avantage_nature, c_base, c_brut, c_cotisation_patronale, c_cotisation_salarie, 
					c_frais_imposables, c_heures_payees, c_heures_travaillees, c_masse_salariale, 
					c_net_a_payer, c_net_imposable, c_nombre, c_od_net_patronale, 
					c_od_net_salarie, chapitre_bulletin, code, code_calcul, code_original, 
					coefficient, coefficient_base, coefficient_nombre, coefficient_txp, 
					coefficient_txs, heures_payees, oid, p_avantage_nature, p_base, 
					p_brut, p_cotisation_patronale, p_cotisation_salarie, p_cumul, 
					p_detail, p_frais_imposables, p_heures_payees, p_heures_travaillees, 
					p_masse_salariale, p_net_a_payer, p_net_imposable, p_nombre, 
					p_od_net_patronale, p_od_net_salarie, rang_edition, s_avantage_nature, 
					s_base, s_brut, s_cotisation_patronale, s_cotisation_salarie, 
					s_frais_imposables, s_heures_payees, s_heures_travaillees, s_masse_salariale, 
					s_net_a_payer, s_net_imposable, s_nombre, s_od_net_patronale, 
					s_od_net_salarie, section_code, section_id, section_texte, texte, 
					texte_court, unite, user_modified
				FROM e_rubriques
				WHERE oid NOT IN (SELECT oid FROM rh.t_rubriques)
				;
				
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Sections analytiques">
			<sqlcmd><![CDATA[	
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_sections_analytiques
					', 'temp e_sections_analytiques'
				);
				
				TRUNCATE rh.t_sections_analytiques
				;

				INSERT INTO rh.t_sections_analytiques(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_sections_analytiques
				WHERE oid NOT IN (SELECT oid FROM rh.t_sections_analytiques)
				;
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_sections_analytiques_paie
					', 'temp e_sections_analytiques_paie'
				);
				
				TRUNCATE rh.t_sections_analytiques_paie
				;

				INSERT INTO rh.t_sections_analytiques_paie(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_sections_analytiques_paie
				WHERE oid NOT IN (SELECT oid FROM rh.t_sections_analytiques_paie)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Services">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_services
					', 'temp e_services'
				);
				
				TRUNCATE rh.t_services
				;

				INSERT INTO rh.t_services(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_services
				WHERE oid NOT IN (SELECT oid FROM rh.t_services)
				;
				
			]]></sqlcmd>
		</NODE>	
		
		<NODE label="Code emploi">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_codes_emploi
					', 'temp e_codes_emploi'
				);
				
				TRUNCATE rh.t_codes_emploi
				;

				INSERT INTO rh.t_codes_emploi(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_codes_emploi
				WHERE oid NOT IN (SELECT oid FROM rh.t_codes_emploi)
				;
				
			]]></sqlcmd>
		</NODE>
		
		<NODE label="Groupe cotisant">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_groupes_cotisant
					', 'temp e_groupes_cotisant'
				);
				
				TRUNCATE rh.t_groupes_cotisant
				;

				INSERT INTO rh.t_groupes_cotisant(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_groupes_cotisant
				WHERE oid NOT IN (SELECT oid FROM rh.t_groupes_cotisant)
				;
				
			]]></sqlcmd>
		</NODE>
				
		<NODE label="Situation famille">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_situations_famille
					', 'temp e_situations_famille'
				);
				
				TRUNCATE rh.t_situations_famille
				;

				INSERT INTO rh.t_situations_famille(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_situations_famille
				WHERE oid NOT IN (SELECT oid FROM rh.t_situations_famille)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Spécialités">
			<sqlcmd><![CDATA[		
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_specialites
					', 'temp e_specialites'
				);
				
				TRUNCATE rh.t_specialites
				;

				INSERT INTO rh.t_specialites(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_specialites
				WHERE oid NOT IN (SELECT oid FROM rh.t_specialites)
				;
			
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Statuts">
			<sqlcmd><![CDATA[				
				
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_statuts
					', 'temp e_statuts'
				);
				
				TRUNCATE rh.t_statuts
				;

				INSERT INTO rh.t_statuts(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_statuts
				WHERE oid NOT IN (SELECT oid FROM rh.t_statuts)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Types contrat">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_types_contrat
					', 'temp e_types_contrat'
				);
				
				TRUNCATE rh.t_types_contrat
				;

				INSERT INTO rh.t_types_contrat(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_types_contrat
				WHERE oid NOT IN (SELECT oid FROM rh.t_types_contrat)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Types horaires">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_types_horaire
					', 'temp e_types_horaire'
				);
				
				TRUNCATE rh.t_types_horaire
				;

				INSERT INTO rh.t_types_horaire(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_types_horaire
				WHERE oid NOT IN (SELECT oid FROM rh.t_types_horaire)
				;
				
			]]></sqlcmd>
		</NODE>	
				
		<NODE label="Types temps travail">
			<sqlcmd><![CDATA[		
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_types_temps_travail
					', 'temp e_types_temps_travail'
				);
				
				TRUNCATE rh.t_types_temps_travail
				;

				INSERT INTO rh.t_types_temps_travail(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_types_temps_travail
				WHERE oid NOT IN (SELECT oid FROM rh.t_types_temps_travail)
				;
				
			]]></sqlcmd>
		</NODE>
		
		<NODE label="Services Planning">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_planning_service
					', 'temp e_planning_service'
				);
				
				TRUNCATE rh.t_planning_service
				;

				INSERT INTO rh.t_planning_service(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court, service_id, service_code, service_texte)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court, service_id, service_code, service_texte
				FROM e_planning_service
				WHERE oid NOT IN (SELECT oid FROM rh.t_planning_service)
				;
				
			]]></sqlcmd>
		</NODE>	
		
		<NODE label="Qualifications Planning">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_planning_qualification
					', 'temp e_planning_qualification'
				);
				
				TRUNCATE rh.t_planning_qualification
				;

				INSERT INTO rh.t_planning_qualification(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court, qualification_id, qualification_code, qualification_texte)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court, qualification_id, qualification_code, qualification_texte
				FROM e_planning_qualification
				WHERE oid NOT IN (SELECT oid FROM rh.t_planning_qualification)
				;
				
			]]></sqlcmd>
		</NODE>	
		
		<NODE label="Niveaux Planning">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_planning_niveau
					', 'temp e_planning_niveau'
				);
				
				TRUNCATE rh.t_planning_niveau
				;

				INSERT INTO rh.t_planning_niveau(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_planning_niveau
				WHERE oid NOT IN (SELECT oid FROM rh.t_planning_niveau)
				;
				
			]]></sqlcmd>
		</NODE>
		
		<NODE label="Absences Planning">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_planning_type_absence
					', 'temp e_planning_type_absence'
				);
				
				TRUNCATE rh.t_planning_type_absence
				;

				INSERT INTO rh.t_planning_type_absence(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_planning_type_absence
				WHERE oid NOT IN (SELECT oid FROM rh.t_planning_type_absence)
				;
				
			]]></sqlcmd>
		</NODE>	
		
			<NODE label="Codes horaires">
			<sqlcmd><![CDATA[		
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_planning_code_horaire
					', 'temp e_planning_code_horaire'
				);
				
				TRUNCATE rh.t_planning_code_horaire
				;

				INSERT INTO rh.t_planning_code_horaire(
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court)
				SELECT 
					code, code_original, oid, section_code, section_id, section_texte, 
					texte, texte_court
				FROM e_planning_code_horaire
				WHERE oid NOT IN (SELECT oid FROM rh.t_planning_code_horaire)
				;
				
			]]></sqlcmd>
		</NODE>	
		
		
		<NODE label="Poles">
			<sqlcmd><![CDATA[
				
					
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM base.t_pole
					', 'temp e_pole'
				);
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_pole_rule
					', 'temp e_pole_rule'
				);

				TRUNCATE base.t_pole;
				INSERT INTO base.t_pole
					(oid, code, texte, texte_court, section_id, section_code, section_texte)
				SELECT oid, code, texte, texte_court, section_id, section_code, section_texte
				FROM e_pole
				;
				TRUNCATE rh.t_pole;
				INSERT INTO rh.t_pole
					(oid, code, texte, texte_court, section_id, section_code, section_texte)
				SELECT oid, code, texte, texte_court, section_id, section_code, section_texte
				FROM e_pole
				;

				TRUNCATE rh.t_pole_rule;
					
				INSERT INTO rh.t_pole_rule
					(oid, code, texte, pole_id, priorite, 
						liste_finess, liste_etablissement, 
						liste_service, liste_specialite, liste_section_analytique, liste_section_analytique_paie, 
						liste_qualification, liste_grille, liste_code_emploi, liste_categorie_socio_professionnelle)
				SELECT oid, code, texte, pole_id, priorite, 
						liste_finess, liste_etablissement, 
						liste_service, liste_specialite, liste_section_analytique, liste_section_analytique_paie, 
						liste_qualification, liste_grille, liste_code_emploi, liste_categorie_socio_professionnelle
				FROM e_pole_rule
				;

			]]></sqlcmd>
		</NODE>
		
		<NODE label="Listes">
			<sqlcmd><![CDATA[		
			
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *, ''0''::text AS ok_liste, 0::bigint AS ok_oid, 0::bigint AS ok_table_id
					FROM rh.t_listes
					WHERE code <> '''' AND
						oid IN (SELECT liste_id FROM rh.t_listes_contenu)
					', 'temp e_listes'
				);
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_listes_contenu
					', 'temp e_listes_contenu'
				);

				UPDATE e_listes
				SET ok_liste = '1', ok_oid = t_listes.oid, ok_table_id = t_listes.table_id
				FROM rh.t_listes
				WHERE e_listes.code = t_listes.code
				;


				DELETE 
				FROM rh.t_listes_contenu
				WHERE liste_id IN (SELECT ok_oid FROM e_listes)
				;

				INSERT INTO rh.t_listes_contenu(liste_id, to_id)
				SELECT ok_oid, to_id
				FROM e_listes_contenu
				JOIN e_listes ON e_listes.oid = e_listes_contenu.liste_id AND ok_liste = '1'
				JOIN rh.t_listes_tables ON ok_table_id = t_listes_tables.oid AND t_listes_tables.code <> 'CPO'
				;

				
			]]></sqlcmd>
		</NODE>
		
		<NODE label="Classes">
			<sqlcmd><![CDATA[		
			
				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *, ''0''::text AS ok_classe, 0::bigint AS ok_classe_id, 0::bigint AS ok_table_id
					FROM rh.t_classes
					WHERE code <> '''' AND
						oid IN (SELECT classe_id FROM rh.t_classes_sections JOIN rh.t_classes_sections_elements ON section_id = t_classes_sections.oid)
					', 'temp e_classes'
				);


				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT t_classes_sections.*, t_classes.code AS classe_code, 0::bigint AS ok_section_id, 0::bigint AS ok_classe_id, 0::bigint AS ok_table_id
					FROM rh.t_classes_sections
					JOIN rh.t_classes ON t_classes_sections.classe_id = t_classes.oid AND
						t_classes.code <> ''''
					', 'temp e_classes_sections'
				);

				
				SELECT base.cti_copy_table('dbname=[DBNAME] port=[DBPORT] host=[DBHOST] user=[DBUSER] password=[DBPASSWORD]', '
					SELECT *
					FROM rh.t_classes_sections_elements
					', 'temp e_classes_sections_elements'
				);

				UPDATE e_classes
				SET ok_classe = '1', ok_classe_id = t_classes.oid, ok_table_id = t_classes.table_id
				FROM rh.t_classes
				WHERE e_classes.code = t_classes.code
				;

				UPDATE e_classes_sections
				SET ok_classe_id = e_classes.ok_classe_id, ok_table_id = e_classes.ok_table_id
				FROM e_classes
				WHERE e_classes_sections.classe_code = e_classes.code AND
					ok_classe = '1'
				;

				UPDATE e_classes_sections
				SET ok_section_id = t_classes_sections.oid
				FROM rh.t_classes_sections
				WHERE t_classes_sections.classe_id = e_classes_sections.ok_classe_id AND
					e_classes_sections.code = t_classes_sections.code
					;

				DELETE 
				FROM rh.t_classes_sections_elements
				WHERE section_id IN (SELECT oid FROM rh.t_classes_sections WHERE classe_id IN (SELECT ok_classe_id FROM e_classes))
				;

				INSERT INTO rh.t_classes_sections_elements(section_id, to_id)
				SELECT ok_section_id, to_id
				FROM e_classes_sections_elements
				JOIN e_classes_sections ON e_classes_sections.oid = e_classes_sections_elements.section_id AND ok_section_id <> 0
				JOIN rh.t_listes_tables ON ok_table_id = t_listes_tables.oid AND t_listes_tables.code <> 'CPO'
				;

				
			]]></sqlcmd>
		</NODE>
		
		
		
	</NODE>
	
</ROOT>
