1+ begin
2+ delete from at_clob where id = '/VIEWDOCS/AV_LOCATION_LEVEL_REF';
3+ insert into at_clob values (cwms_seq.nextval, 53, '/VIEWDOCS/AV_LOCATION_LEVEL_REF', null,
4+ '
5+ /**
6+ * Displays information about location level IDs
7+ *
8+ * @field office_id Office that owns the location level
9+ * @field location_level_id The unique identifier for the location level
10+ * @field attribute_id The attribute identifier, if any, for the location level
11+ * @field location_level_code The unique numeric code that identifies the location level in the database
12+ * @field location_level_date The effective data for the location level
13+ * @field expiration_date The date/time at which the level expires
14+ * @field base_location_id The base location portion of the location level
15+ * @field sub_location_id The sub-location portion of the location level
16+ * @field location_id The full location portion of the location level
17+ * @field location_code The unique numeric code that identifies the location in the database
18+ * @field base_parameter_id The base parameter portion of the location level
19+ * @field sub_parameter_id The sub-parameter portion of the location level
20+ * @field parameter_id The full parameter portion of the location level
21+ * @field parameter_type_id The parameter type of the location level
22+ * @field location_level_comment The comment associated with the location level
23+ * @field duration_id The duration portion of the location level
24+ * @field specified_level_id The specified level portion of the location level
25+ * @field attribute_parameter_id The attribute of the parameter, if any
26+ * @field attribute_base_parameter_id The base parameter of the attribute, if any
27+ * @field attribute_sub_parameter_id The sub-parameter of the attribute, if any
28+ * @field attribute_parameter_type_id The parameter type of the attribute, if any
29+ * @field attribute_duration_id The duration of the attribute, if any
30+ */
31+ ');
32+ end;
33+ /
34+ create or replace force view av_location_level_ref
35+ (
36+ office_id,
37+ location_level_id,
38+ attribute_id,
39+ location_level_code,
40+ location_level_date,
41+ expiration_date,
42+ base_location_id,
43+ sub_location_id,
44+ location_id,
45+ location_code,
46+ base_parameter_id,
47+ sub_parameter_id,
48+ parameter_id,
49+ parameter_type_id,
50+ location_level_comment,
51+ duration_id,
52+ specified_level_id,
53+ attribute_parameter_id,
54+ attribute_base_parameter_id,
55+ attribute_sub_parameter_id,
56+ attribute_parameter_type_id,
57+ attribute_duration_id
58+ )
59+ as
60+ /* ===========================
61+ * PHYSICAL LOCATION LEVELS
62+ * =========================== */
63+ select
64+ c_o.office_id,
65+ (dash(a_bl.base_location_id, a_pl.sub_location_id) || '.' || dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) || '.' || c_pt1.parameter_type_id || '.' || c_d1.duration_id || '.' || a_sl.specified_level_id) as location_level_id,
66+ (dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) || substr ('.', 1, length (c_pt2.parameter_type_id)) || c_pt2.parameter_type_id || substr ('.', 1, length (c_d2.duration_id)) || c_d2.duration_id) as attribute_id,
67+ a_ll.location_level_code,
68+ a_ll.location_level_date,
69+ a_ll.expiration_date,
70+ a_bl.base_location_id,
71+ a_pl.sub_location_id,
72+ dash(a_bl.base_location_id, a_pl.sub_location_id) as location_id,
73+ a_ll.location_code,
74+ c_bp1.base_parameter_id,
75+ a_p1.sub_parameter_id,
76+ dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) as parameter_id,
77+ c_pt1.parameter_type_id,
78+ a_ll.location_level_comment,
79+ c_d1.duration_id,
80+ a_sl.specified_level_id,
81+ dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) as parameter_id,
82+ c_bp2.base_parameter_id as attribute_base_parameter_id,
83+ a_p2.sub_parameter_id as attribute_sub_parameter_id,
84+ c_pt2.parameter_type_id as attribute_parameter_type_id,
85+ c_d2.duration_id as attribute_duration_id
86+ from
87+ at_location_level a_ll
88+ join at_physical_location a_pl
89+ on a_pl.location_code = a_ll.location_code
90+ join at_base_location a_bl
91+ on a_bl.base_location_code = a_pl.base_location_code
92+ join cwms_office c_o
93+ on c_o.office_code = a_bl.db_office_code
94+ join at_specified_level a_sl
95+ on a_sl.specified_level_code = a_ll.specified_level_code
96+ join cwms_duration c_d1
97+ on c_d1.duration_code = a_ll.duration_code
98+ join cwms_parameter_type c_pt1
99+ on c_pt1.parameter_type_code = a_ll.parameter_type_code
100+ join at_parameter a_p1
101+ on a_p1.parameter_code = a_ll.parameter_code
102+ join cwms_base_parameter c_bp1
103+ on c_bp1.base_parameter_code = a_p1.base_parameter_code
104+ left join at_parameter a_p2
105+ on a_p2.parameter_code = a_ll.attribute_parameter_code
106+ left join cwms_base_parameter c_bp2
107+ on c_bp2.base_parameter_code = a_p2.base_parameter_code
108+ left join cwms_parameter_type c_pt2
109+ on c_pt2.parameter_type_code = a_ll.attribute_parameter_type_code
110+ left join cwms_duration c_d2
111+ on c_d2.duration_code = a_ll.attribute_duration_code
112+ union all
113+ /* ===========================
114+ * VIRTUAL LOCATION LEVELS
115+ * =========================== */
116+ select
117+ c_o.office_id,
118+ (dash(a_bl.base_location_id, a_pl.sub_location_id) || '.' || dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) || '.' || c_pt1.parameter_type_id || '.' || c_d1.duration_id || '.' || a_sl.specified_level_id) as location_level_id,
119+ (dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) || substr ('.', 1, length (c_pt2.parameter_type_id)) || c_pt2.parameter_type_id || substr ('.', 1, length (c_d2.duration_id)) || c_d2.duration_id) as attribute_id,
120+ v_ll.location_level_code,
121+ v_ll.effective_date as location_level_date,
122+ v_ll.expiration_date,
123+ a_bl.base_location_id,
124+ a_pl.sub_location_id,
125+ dash(a_bl.base_location_id, a_pl.sub_location_id) as location_id,
126+ v_ll.location_code,
127+ c_bp1.base_parameter_id,
128+ a_p1.sub_parameter_id,
129+ dash(c_bp1.base_parameter_id, a_p1.sub_parameter_id) as parameter_id,
130+ c_pt1.parameter_type_id,
131+ v_ll.location_level_comment,
132+ c_d1.duration_id,
133+ a_sl.specified_level_id,
134+ dash(c_bp2.base_parameter_id, a_p2.sub_parameter_id) as parameter_id,
135+ c_bp2.base_parameter_id as attribute_base_parameter_id,
136+ a_p2.sub_parameter_id as attribute_sub_parameter_id,
137+ c_pt2.parameter_type_id as attribute_parameter_type_id,
138+ c_d2.duration_id as attribute_duration_id
139+ from
140+ at_virtual_location_level v_ll
141+ join at_physical_location a_pl
142+ on a_pl.location_code = v_ll.location_code
143+ join at_base_location a_bl
144+ on a_bl.base_location_code = a_pl.base_location_code
145+ join cwms_office c_o
146+ on c_o.office_code = a_bl.db_office_code
147+ join at_specified_level a_sl
148+ on a_sl.specified_level_code = v_ll.specified_level_code
149+ join cwms_duration c_d1
150+ on c_d1.duration_code = v_ll.duration_code
151+ join cwms_parameter_type c_pt1
152+ on c_pt1.parameter_type_code = v_ll.parameter_type_code
153+ join at_parameter a_p1
154+ on a_p1.parameter_code = v_ll.parameter_code
155+ join cwms_base_parameter c_bp1
156+ on c_bp1.base_parameter_code = a_p1.base_parameter_code
157+ left join at_parameter a_p2
158+ on a_p2.parameter_code = v_ll.attribute_parameter_code
159+ left join cwms_base_parameter c_bp2
160+ on c_bp2.base_parameter_code = a_p2.base_parameter_code
161+ left join cwms_parameter_type c_pt2
162+ on c_pt2.parameter_type_code = v_ll.attribute_parameter_type_code
163+ left join cwms_duration c_d2
164+ on c_d2.duration_code = v_ll.attribute_duration_code;
165+ /
166+ begin
167+ execute immediate 'grant select on av_location_level_ref to cwms_user';
168+ exception
169+ when others then null;
170+ end;
171+ /
172+ create or replace public synonym cwms_v_location_level_ref for av_location_level_ref;
173+ /
0 commit comments