|
41 | 41 | 'Session requires new LRTS ID format. Invalid ID: '||p_cwms_ts_id); |
42 | 42 | end new_lrts_id_required_error; |
43 | 43 |
|
| 44 | + procedure old_lrts_id_required_error( |
| 45 | + p_cwms_ts_id in varchar2) |
| 46 | + is |
| 47 | + begin |
| 48 | + cwms_err.raise( |
| 49 | + 'ERROR', |
| 50 | + 'Session requires old LRTS ID format. Invalid ID: '||p_cwms_ts_id); |
| 51 | + end old_lrts_id_required_error; |
| 52 | + |
| 53 | + procedure not_lrts_error( |
| 54 | + p_cwms_ts_id in varchar2) |
| 55 | + is |
| 56 | + begin |
| 57 | + cwms_err.raise( |
| 58 | + 'ERROR', |
| 59 | + 'Invalid ID for PRTS: '||p_cwms_ts_id); |
| 60 | + end not_lrts_error; |
| 61 | + |
44 | 62 | procedure clear_all_caches |
45 | 63 | is |
46 | 64 | begin |
|
3026 | 3044 | clear_all_caches; |
3027 | 3045 | end set_require_new_lrts_format_on_input; |
3028 | 3046 | -------------------------------------------------------------------------------- |
3029 | | - -- function function require_new_lrts_format_on_input |
| 3047 | + -- function require_new_lrts_format_on_input |
3030 | 3048 | -------------------------------------------------------------------------------- |
3031 | 3049 | function require_new_lrts_format_on_input |
3032 | 3050 | return varchar2 |
|
3038 | 3056 | end; |
3039 | 3057 | end require_new_lrts_format_on_input; |
3040 | 3058 | -------------------------------------------------------------------------------- |
3041 | | - -- function retrieve_ts_raw |
| 3059 | + -- procedure retrieve_ts_raw |
3042 | 3060 | -------------------------------------------------------------------------------- |
3043 | 3061 | procedure retrieve_ts_raw( |
3044 | 3062 | p_ts_retrieved in out nocopy ztsv_entry_array, |
@@ -3229,9 +3247,11 @@ AS |
3229 | 3247 | l_ts_code at_cwms_ts_id.ts_code%type; |
3230 | 3248 | l_office_id cwms_office.office_id%type; |
3231 | 3249 | l_cwms_ts_id at_cwms_ts_id.cwms_ts_id%type; |
| 3250 | + l_parts str_tab_t; |
3232 | 3251 | l_location_id av_loc.location_id%type; |
3233 | 3252 | l_location_code at_physical_location.location_code%type; |
3234 | 3253 | l_parameter_id at_cwms_ts_id.parameter_id%type; |
| 3254 | + l_interval_id at_cwms_ts_id.interval_id%type; |
3235 | 3255 | l_unit_id at_cwms_ts_id.unit_id%type; |
3236 | 3256 | l_time_zone_in cwms_time_zone.time_zone_name%type; |
3237 | 3257 | l_time_zone_out cwms_time_zone.time_zone_name%type; |
@@ -3276,21 +3296,38 @@ AS |
3276 | 3296 | l_office_id := cwms_util.get_db_office_id(p_office_id); |
3277 | 3297 | l_cwms_ts_id := get_ts_id(p_cwms_ts_id, l_office_id); |
3278 | 3298 | l_retrieve_data_entry := cwms_util.return_true_or_false(p_retrieve_data_entry); |
| 3299 | + l_interval_id := cwms_util.split_text(p_cwms_ts_id, 4, '.'); |
3279 | 3300 | if l_cwms_ts_id is null then |
3280 | 3301 | cwms_err.raise('TS_ID_NOT_FOUND', p_cwms_ts_id, l_office_id); |
3281 | 3302 | elsif use_new_lrts_format_on_output = 'T' |
3282 | | - and substr(cwms_util.split_text(p_cwms_ts_id, 4, '.'), 1, 1) = '~' |
| 3303 | + and substr(l_interval_id, 1, 1) = '~' |
3283 | 3304 | and upper(substr(cwms_util.split_text(l_cwms_ts_id, 4, '.'), -5)) = 'LOCAL' |
3284 | 3305 | then |
3285 | 3306 | ---------------------------------- |
3286 | 3307 | -- convert back to input format -- |
3287 | 3308 | ---------------------------------- |
3288 | 3309 | l_cwms_ts_id := regexp_replace(l_cwms_ts_id, '\.([[:digit:]]+[[:alpha:]]+)Local\.', '.~\1.', 1, 1, 'i'); |
3289 | 3310 | end if; |
| 3311 | + l_ts_code := get_ts_code(p_cwms_ts_id, l_office_id); |
| 3312 | + ---------------------------------------------- |
| 3313 | + -- verify correct TSID format for actual TS -- |
| 3314 | + ---------------------------------------------- |
| 3315 | + if is_lrts(l_ts_code) = 'T' then |
| 3316 | + if require_new_lrts_format_on_input = 'T' then |
| 3317 | + if substr(l_interval_id, 1, 1) = '~' then |
| 3318 | + new_lrts_id_required_error(l_cwms_ts_id); |
| 3319 | + end if; |
| 3320 | + elsif upper(substr(l_interval_id, -5)) = 'LOCAL' then |
| 3321 | + if 'T' not in (require_new_lrts_format_on_input, allow_new_lrts_format_on_input) then |
| 3322 | + old_lrts_id_required_error(l_cwms_ts_id); |
| 3323 | + end if; |
| 3324 | + end if; |
| 3325 | + elsif upper(substr(l_interval_id, -5)) = 'LOCAL' then |
| 3326 | + not_lrts_error(l_cwms_ts_id); |
| 3327 | + end if; |
3290 | 3328 | l_location_id := cwms_util.split_text(l_cwms_ts_id, 1, '.'); |
3291 | 3329 | l_location_code := cwms_loc.get_location_code(l_office_id, l_location_id); |
3292 | 3330 | l_parameter_id := cwms_util.split_text(l_cwms_ts_id, 2, '.'); |
3293 | | - l_ts_code := get_ts_code(p_cwms_ts_id, l_office_id); |
3294 | 3331 | l_location_code := cwms_loc.get_location_code(l_office_id, cwms_util.split_text(l_cwms_ts_id, 1, '.')); |
3295 | 3332 | l_time_zone_out := cwms_loc.get_local_timezone(substr(l_cwms_ts_id, 1, instr(l_cwms_ts_id, '.') - 1), l_office_id); |
3296 | 3333 | l_time_zone_in := case when p_time_zone is null then l_time_zone_out else cwms_util.get_timezone(p_time_zone) end; |
@@ -5724,13 +5761,19 @@ AS |
5724 | 5761 | get_ts_code (p_cwms_ts_id => l_cwms_ts_id, |
5725 | 5762 | p_db_office_code => l_office_code); |
5726 | 5763 |
|
| 5764 | + l_is_lrts := is_lrts(l_ts_code) = 'T'; |
| 5765 | + if l_is_lrts and |
| 5766 | + require_new_lrts_format_on_input = 'T' and |
| 5767 | + substr(cwms_util.split_text(p_cwms_ts_id, 4, '.'), 1, 1) = '~' |
| 5768 | + then |
| 5769 | + new_lrts_id_required_error(l_cwms_ts_id); |
| 5770 | + end if; |
| 5771 | + |
5727 | 5772 | SELECT interval_utc_offset |
5728 | 5773 | INTO existing_utc_offset |
5729 | 5774 | FROM at_cwms_ts_spec |
5730 | 5775 | WHERE ts_code = l_ts_code; |
5731 | 5776 |
|
5732 | | - l_is_lrts := is_lrts(l_ts_code) = 'T'; |
5733 | | - |
5734 | 5777 | if l_is_lrts then |
5735 | 5778 | l_irr_offset := existing_utc_offset; |
5736 | 5779 | l_loc_tz := cwms_loc.get_local_timezone(l_location_code); |
|
5792 | 5835 | p_utc_offset => l_utc_offset); |
5793 | 5836 | existing_utc_offset := l_utc_offset; |
5794 | 5837 | WHEN OTHERS THEN |
5795 | | - dbms_output.put_line('==> ERROR is '||sqlerrm); |
5796 | 5838 | cwms_err.raise('ERROR', dbms_utility.format_error_backtrace); |
5797 | 5839 | END; -- END - Find TS_CODE |
5798 | 5840 |
|
@@ -6038,16 +6080,6 @@ AS |
6038 | 6080 | from table(l_timeseries_data); |
6039 | 6081 | exception |
6040 | 6082 | when too_many_rows then |
6041 | | - dbms_output.enable; |
6042 | | - dbms_output.put_line('time series id = '||l_cwms_ts_id); |
6043 | | - dbms_output.put_line('interval = '||l_irr_interval); |
6044 | | - dbms_output.put_line('local time zone = '||l_loc_tz); |
6045 | | - for i in 1..l_timeseries_data.count loop |
6046 | | - dbms_output.put(i||chr(9)||l_timeseries_data(i).date_time); |
6047 | | - dbms_output.put(chr(9)||from_tz(cwms_util.change_timezone(cast(l_timeseries_data(i).date_time as timestamp), extract(timezone_region from l_timeseries_data(i).date_time), l_loc_tz), l_loc_tz)); |
6048 | | - dbms_output.put(chr(9)||get_utc_interval_offset(from_tz(cwms_util.change_timezone(cast(l_timeseries_data(i).date_time as timestamp), extract(timezone_region from l_timeseries_data(i).date_time), l_loc_tz), l_loc_tz), l_irr_interval)); |
6049 | | - dbms_output.new_line; |
6050 | | - end loop; |
6051 | 6083 | raise_application_error ( |
6052 | 6084 | -20110, |
6053 | 6085 | 'ERROR: Incoming data set contains multiple interval offsets. Unable to store data for ' |
|
0 commit comments