 	count(s.*) AS count_valid_data
 FROM gn_synthese.synthese s
 LEFT JOIN taxonomie.taxref t ON s.cd_nom=t.cd_nom
-CROSS JOIN gn_profiles.get_profiles_parameters(s.cd_nom) p
+CROSS JOIN gn_profiles.get_parameters(s.cd_nom) p
 WHERE p.spatial_precision IS NOT NULL AND ST_MaxDistance(ST_centroid(s.the_geom_local), s.the_geom_local)<p.spatial_precision 
-AND s.id_nomenclature_valid_status IN (SELECT regexp_split_to_table(profiles_parameter_value, ',')::integer FROM gn_profiles.t_profiles_parameters WHERE profiles_parameter_name='id_valid_status_for_profiles')
+AND s.id_nomenclature_valid_status IN (SELECT regexp_split_to_table(profiles_parameter_value, ',')::integer FROM gn_profiles.t_parameters WHERE profiles_parameter_name='id_valid_status_for_profiles')
 GROUP BY t.cd_ref;
 
 


CREATE TABLE gn_profiles.t_altitude_ranges(
	id_altitude_range serial,
	label_range character varying(50),
	alt_min_range integer,
	alt_max_range integer
);

---------------
--PRIMARY KEY--
---------------
ALTER TABLE ONLY gn_profiles.t_profiles_parameters ADD CONSTRAINT pk_profiles_parameters PRIMARY KEY (id_profile_parameter);

ALTER TABLE ONLY gn_profiles.t_profiles_parameters ADD CONSTRAINT fk_t_profiles_parameters_bib_organismes FOREIGN KEY (id_organism) REFERENCES utilisateurs.bib_organismes(id_organisme) ON UPDATE CASCADE;

ALTER TABLE ONLY gn_profiles.cor_taxons_profiles_parameters ADD CONSTRAINT pk_taxons_profiles_parameters PRIMARY KEY (cd_ref);


--TABLES--
----------

CREATE TABLE gn_profiles.t_parameters(
	id_parameter serial NOT NULL,
	id_organism int4 NULL,
	name varchar(100) NOT NULL,
	desc text NULL,
	value text NOT NULL,
	extra_value varchar(255) NULL
);


CREATE TABLE gn_profiles.cor_taxons_parameters(
	cd_ref integer,
	spatial_precision integer,
	temporal_precision_days integer, 
