 end;
 $$;
 
-select indMergeCountMinMax() as MergeIndividualsCountMinAndMax;
-
 create function eraseDupliInd () returns boolean language plpgsql as $$
 declare
   rowsDeleted integer := 0;
 begin
-  select count(*) into rowsDeleted from (select fct_explode_array(individual_ids) from spec_ind_dupli) as x;
+  select count(*) into rowsDeleted from (select distinct fct_explode_array(individual_ids) from spec_ind_dupli) as x;
   RAISE NOTICE '% individuals in total.', rowsDeleted;
   select count(distinct individual_merge_into) into rowsDeleted from spec_ind_dupli;
   RAISE NOTICE '% distinct individuals to merge into.', rowsDeleted;

  GET DIAGNOSTICS rowsDeleted = ROW_COUNT;
  RAISE NOTICE '% rows deleted.', rowsDeleted;
  return true;
end;
$$;

select eraseDupliInd() as IndividualsInDuplicationDeleted;

drop function if exists updateParts();
drop function if exists updatePeriphData(table_concerned varchar);
drop function if exists indMergeCountMinMax();
drop function if exists eraseDupliInd();

rollback;

end;
$$;

create or replace function indMergeCountMinMax () returns boolean language plpgsql as $$
declare
  recConcerned RECORD;
