         END;
     END IF;
     --test si la table source et de destination existe et si un maping des champs a été préparé.
-    insertfield = format('INSERT INTO %I.%I(',tsname, ttname);
-    selectfield = 'SELECT ';
-    FOR r IN EXECUTE format('SELECT source_field, target_field, target_field_type 
+    insertfield = format('INSERT INTO %I.%I(%s',tsname, ttname, chr(10));
+    selectfield = concat('SELECT ',chr(10));
+    FOR r IN EXECUTE format('SELECT source_field, source_default_value, target_field, target_field_type 
 			     FROM gn_imports.matching_fields f
 			     JOIN gn_imports.matching_tables t ON t.id_matching_table = f.id_matching_table
 			     WHERE t.source_schema = %L 

    ADD CONSTRAINT fk_matching_geoms_matching_tables FOREIGN KEY (id_matching_table) REFERENCES matching_tables(id_matching_table) ON UPDATE CASCADE ON DELETE NO ACTION;
ALTER TABLE ONLY matching_fields
    ADD CONSTRAINT fk_matching_fields_matching_tables FOREIGN KEY (id_matching_table) REFERENCES matching_tables(id_matching_table) ON UPDATE CASCADE ON DELETE NO ACTION;


-------------

			     AND t.target_table = %L'
			     ,ssname, stname,tsname, ttname)
    LOOP
        insertfield := concat(insertfield, virgule, r.target_field, chr(10));
        selectfield := concat(
				selectfield, 
				virgule, 
				COALESCE('a.'||r.source_field, r.source_default_value),
				'::',
				r.target_field_type, 
				' AS ', 
				r.target_field,
				chr(10));
        virgule := ',';
    END LOOP;
    --gestion du geom avec la table gn_imports.matching_geoms
    FOR g IN EXECUTE format('SELECT g.* FROM gn_imports.matching_geoms g
