File indexing completed on 2024-04-06 12:23:00
0001 CREATE OR REPLACE
0002 PROCEDURE update_online_pvss_iov_number
0003 ( cndc_table IN VARCHAR2,
0004 new_since IN NUMBER,
0005 new_till IN NUMBER,
0006 logic_id IN INTEGER ) IS
0007
0008
0009
0010
0011
0012
0013 sql_str VARCHAR(1000);
0014 future_since NUMBER;
0015 last_since NUMBER;
0016 last_till NUMBER;
0017
0018 BEGIN
0019
0020 IF new_till <= new_since THEN
0021 raise_application_error(-20000, 'IoV must have since < till');
0022 END IF;
0023
0024
0025 sql_str := 'SELECT max(since) FROM ' || cndc_table || ' WHERE since > :s and logic_id=:l';
0026 EXECUTE IMMEDIATE sql_str INTO future_since USING new_since,logic_id;
0027
0028 IF future_since IS NOT NULL THEN
0029 raise_application_error(-20010, 'IoVs must be inserted in increasing order: ' ||
0030 'Current highest ''since'' is ' ||
0031 to_char(future_since));
0032 END IF;
0033
0034
0035 sql_str := 'SELECT max(since) FROM ' || cndc_table || ' WHERE since <= :s and logic_id=:l';
0036 EXECUTE IMMEDIATE sql_str INTO last_since USING new_since,logic_id;
0037
0038 IF last_since IS NULL THEN
0039
0040 return;
0041 END IF;
0042
0043
0044 sql_str := 'SELECT till FROM ' || cndc_table || ' WHERE since = :s and logic_id=:l';
0045 EXECUTE IMMEDIATE sql_str INTO last_till USING last_since,logic_id;
0046
0047 IF new_since = last_since THEN
0048
0049 raise_application_error(-20020, 'New IOV since overlaps older since');
0050 ELSIF new_since < last_till THEN
0051
0052 sql_str := 'UPDATE ' || cndc_table || ' SET till = :new_since WHERE since = :last_since AND till = :last_till and logic_id=:l';
0053 EXECUTE IMMEDIATE sql_str USING new_since, last_since, last_till,logic_id;
0054 END IF;
0055 END;
0056 /
0057 show errors;