[Dive4elements-commits] [PATCH 1 of 2] Schema change: view for WSTs which deales with multiple ranges matching station (issues 1315 and 1296)
Wald Commits
scm-commit at wald.intevation.org
Thu May 23 17:32:56 CEST 2013
# HG changeset patch
# User Tom Gottfried <tom.gottfried at intevation.de>
# Date 1369323140 -7200
# Node ID 176664f84d865e0eaac7ba5e75e118ad83b739b2
# Parent c97d003fd1273c9bb02570f842fce89f8d121099
Schema change: view for WSTs which deales with multiple ranges matching station (issues 1315 and 1296)
diff -r c97d003fd127 -r 176664f84d86 backend/doc/schema/oracle.sql
--- a/backend/doc/schema/oracle.sql Thu May 23 15:11:05 2013 +0200
+++ b/backend/doc/schema/oracle.sql Thu May 23 17:32:20 2013 +0200
@@ -414,25 +414,25 @@
-- VIEWS
CREATE VIEW wst_value_table AS
- SELECT wcv.position AS position,
- w,
- (SELECT q
- FROM wst_column_q_ranges wcqr
- JOIN wst_q_ranges wqr
- ON wcqr.wst_q_range_id = wqr.id
- JOIN ranges r
- ON r.id = wqr.range_id
- WHERE wcqr.wst_column_id = wc.id
- AND wcv.position BETWEEN r.a AND r.b) AS q,
- wc.position AS column_pos,
- w.id AS wst_id
- FROM wst_column_values wcv
- JOIN wst_columns wc
- ON wcv.wst_column_id = wc.id
- JOIN wsts w
- ON wc.wst_id = w.id
+ SELECT
+ wcv.position AS position,
+ w,
+ q,
+ wc.position AS column_pos,
+ w.id AS wst_id
+ FROM wsts w
+ JOIN wst_columns wc
+ ON wc.wst_id=w.id
+ JOIN wst_column_q_ranges wcqr
+ ON wcqr.wst_column_id=wc.id
+ JOIN wst_q_ranges wqr
+ ON wcqr.wst_q_range_id=wqr.id
+ JOIN ranges r
+ ON wqr.range_id=r.id
+ JOIN wst_column_values wcv
+ ON wcv.wst_column_id=wc.id AND wcv.position between r.a and r.b;
ORDER BY wcv.position ASC,
- wc.position DESC;
+ wc.position DESC;
-- view to select the w values of a WST
CREATE VIEW wst_w_values AS
diff -r c97d003fd127 -r 176664f84d86 backend/doc/schema/postgresql.sql
--- a/backend/doc/schema/postgresql.sql Thu May 23 15:11:05 2013 +0200
+++ b/backend/doc/schema/postgresql.sql Thu May 23 17:32:20 2013 +0200
@@ -243,25 +243,25 @@
);
CREATE VIEW wst_value_table AS
- SELECT wcv.position AS position,
- w,
- (SELECT q
- FROM wst_column_q_ranges wcqr
- JOIN wst_q_ranges wqr
- ON wcqr.wst_q_range_id = wqr.id
- JOIN ranges r
- ON r.id = wqr.range_id
- WHERE wcqr.wst_column_id = wc.id
- AND wcv.position BETWEEN r.a AND r.b) AS q,
- wc.position AS column_pos,
- w.id AS wst_id
- FROM wst_column_values wcv
- JOIN wst_columns wc
- ON wcv.wst_column_id = wc.id
- JOIN wsts w
- ON wc.wst_id = w.id
+ SELECT
+ wcv.position AS position,
+ w,
+ q,
+ wc.position AS column_pos,
+ w.id AS wst_id
+ FROM wsts w
+ JOIN wst_columns wc
+ ON wc.wst_id=w.id
+ JOIN wst_column_q_ranges wcqr
+ ON wcqr.wst_column_id=wc.id
+ JOIN wst_q_ranges wqr
+ ON wcqr.wst_q_range_id=wqr.id
+ JOIN ranges r
+ ON wqr.range_id=r.id
+ JOIN wst_column_values wcv
+ ON wcv.wst_column_id=wc.id AND wcv.position between r.a and r.b;
ORDER BY wcv.position ASC,
- wc.position DESC;
+ wc.position DESC;
-- view to select the w values of a WST
CREATE VIEW wst_w_values AS
More information about the Dive4elements-commits
mailing list