sascha@371: sascha@371: sascha@404: sascha@404: sascha@404: sascha@404: SELECT id AS river_id, name as river_name FROM rivers sascha@415: WHERE name ILIKE ${river} sascha@404: sascha@404: sascha@409: sascha@409: sascha@404: sascha@404: sascha@404: sascha@371: sascha@371: sascha@404: SELECT id AS gauge_id, sascha@404: name AS gauge_name sascha@404: FROM gauges WHERE river_id = ${river_id} sascha@371: sascha@371: sascha@404: sascha@404: sascha@404: sascha@371: sascha@371: sascha@404: SELECT description AS gauge_desc, sascha@404: d.id AS discharge_id, sascha@404: ti.start_time AS g_start, sascha@404: ti.stop_time AS g_stop sascha@404: FROM discharge_tables d JOIN time_intervals ti sascha@404: ON d.time_interval_id = ti.id sascha@404: WHERE d.gauge_id = ${gauge_id} AND d.kind = 1 sascha@371: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@371: sascha@371: sascha@404: sascha@371: sascha@371: sascha@404: sascha@404: sascha@405: sascha@404: sascha@404: sascha@404: SELECT id AS fix_id, sascha@404: description AS fix_description sascha@404: FROM wsts WHERE kind = 2 AND river_id = ${river_id} sascha@404: sascha@404: sascha@404: sascha@404: sascha@409: sascha@409: sascha@409: sascha@409: sascha@409: SELECT id AS fix_column_id, sascha@409: name AS fix_column_name sascha@409: FROM wst_columns WHERE wst_id = ${fix_id} sascha@409: ORDER by position sascha@409: sascha@409: sascha@409: sascha@409: sascha@409: sascha@409: sascha@409: sascha@409: sascha@409: sascha@404: sascha@404: sascha@404: sascha@404: sascha@405: sascha@404: sascha@404: sascha@404: SELECT id AS prot_id, sascha@404: description AS prot_description sascha@404: FROM wsts WHERE kind = 5 AND river_id = ${river_id} sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: SELECT id AS prot_column_id, sascha@404: name AS prot_column_name sascha@404: FROM wst_columns WHERE wst_id = ${prot_id} sascha@404: ORDER by position sascha@404: sascha@404: sascha@404: sascha@409: sascha@409: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@405: sascha@404: sascha@404: sascha@404: SELECT id AS fw_id, sascha@404: description AS fw_description sascha@404: FROM wsts WHERE kind = 4 AND river_id = ${river_id} sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: SELECT id AS fw_column_id, sascha@404: name AS fw_column_name sascha@404: FROM wst_columns WHERE wst_id = ${fw_id} sascha@404: ORDER by position sascha@404: sascha@404: sascha@404: sascha@409: sascha@409: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@405: sascha@404: sascha@404: sascha@404: SELECT id AS wl_id, sascha@404: description AS wl_description sascha@404: FROM wsts WHERE kind = 0 AND river_id = ${river_id} sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: SELECT id AS wl_column_id, sascha@404: name AS wl_column_name sascha@404: FROM wst_columns WHERE wst_id = ${wl_id} sascha@404: ORDER by position sascha@404: sascha@404: sascha@404: sascha@409: sascha@409: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@405: sascha@404: sascha@404: sascha@404: SELECT id AS els_id, sascha@404: description AS els_description sascha@404: FROM wsts WHERE kind = 1 AND river_id = ${river_id} sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: SELECT id AS els_column_id, sascha@404: name AS els_column_name sascha@404: FROM wst_columns WHERE wst_id = ${els_id} sascha@404: ORDER by position sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@404: sascha@405: sascha@405: sascha@405: sascha@405: sascha@405: sascha@405: sascha@405: sascha@409: sascha@404: sascha@404: sascha@404: sascha@371: sascha@371: