1: function apm_upgrade_for_version_p(
2: v_path in varchar,
3: v_initial_version_name in varchar,
4: v_final_version_name in varchar
5: )
6: return char
7: is
8: a_pos1 integer;
9: a_pos2 integer;
10: a_path varchar(4000);
11: a_version_from varchar(4000);
12: a_version_to varchar(4000);
13: begin
14: -- Set a_path to the tail of the path (the file name).
15: a_path := substr(v_path, instr(v_path, '/', -1) + 1);
16:
17: -- Remove the extension, if it's .sql.
18: a_pos1 := instr(a_path, '.', -1);
19: if a_pos1 > 0 and substr(a_path, a_pos1) = '.sql' then
20: a_path := substr(a_path, 1, a_pos1 - 1);
21: end if;
22:
23: -- Figure out the from/to version numbers for the individual file.
24: a_pos1 := instr(a_path, '-', -1, 2);
25: a_pos2 := instr(a_path, '-', -1);
26: if a_pos1 = 0 or a_pos2 = 0 then
27: -- There aren't two hyphens in the file name. Bail.
28: return 'f';
29: end if;
30:
31: a_version_from := substr(a_path, a_pos1 + 1, a_pos2 - a_pos1 - 1);
32: a_version_to := substr(a_path, a_pos2 + 1);
33:
34: if apm_version_order(v_initial_version_name) <= apm_version_order(a_version_from) and
35: apm_version_order(v_final_version_name) >= apm_version_order(a_version_to) then
36: return 't';
37: end if;
38:
39: return 'f';
40: exception when others then
41: -- Invalid version number.
42: return 'f';
43: end;
|