DBA Data[Home] [Help]

PACKAGE BODY: APPS.AD_FEATURE_VERS_PKG

Source


1 package body ad_feature_vers_pkg as
2 /* $Header: adufeatb.pls 115.3 2003/04/10 21:19:38 vharihar ship $ */
3 
4 
5 --
6 -- Public program units
7 --
8 
9 procedure load_row
10 (
11   p_feature_name       varchar2,
12   p_db_version         number,
13   p_enabled_flag       varchar2,
14   p_rcs_file_keyword   varchar2,
15   p_rcs_vers_keyword   varchar2
16 )
17 is
18   l_actual_filename varchar2(80) := null;      -- after stripping out RCS stuff
19   l_actual_rcs_version varchar2(161) := null;  -- after stripping out RCS stuff
20 
21   l_curr_rcs_version varchar2(150) := null;    -- as recorded in DB
22 
23   l_colon_pos number := 0;
24   l_len number := 0;
25   l_num number := 0;
26 begin
27 
28   begin
29     -- get the RCS filename
30     -- eg. adufeatb.pls is embedded as '$RCSfile: adufeatb.pls,v $'
31     --     (without the quotes)
32 
33     l_colon_pos := instr(p_rcs_file_keyword, ':');
34     l_len := length(p_rcs_file_keyword);
35     l_actual_filename := substr(p_rcs_file_keyword,
36                                 l_colon_pos+2, l_len - l_colon_pos - 5);
37 
38     -- get the RCS version
39     -- eg. 115.1 is embedded as '$Revision: 115.3 $' (without the quotes)
40 
41     l_colon_pos := instr(p_rcs_vers_keyword, ':');
42     l_len := length(p_rcs_vers_keyword);
43     l_actual_rcs_version := substr(p_rcs_vers_keyword,
44                                    l_colon_pos+2, l_len - l_colon_pos - 3);
45 
46     -- validate that its all numeric (strip out the dot (.))
47 
48     l_num := to_number(translate(l_actual_rcs_version,
49                                  '0123456789.',
50                                  '0123456789'));
51 
52     if nvl(l_num, 0) = 0 then
53       raise VALUE_ERROR ;
54     end if;
55 
56   exception when others then
57     raise_application_error(-20000, 'Invalid RCS entry '||
58                                  p_rcs_file_keyword||', '||p_rcs_vers_keyword);
59   end;
60 
61   select rcs_version
62   into l_curr_rcs_version
63   from ad_feature_versions
64   where feature_name = p_feature_name
65   for update;
66 
67   if l_curr_rcs_version = '0' then
68     -- Bootstrap code.
69 
70     -- These columns were just added, we need to populate them (ODF defaults
71     -- the value of the FEATURE_NAME column into FILENAME, and '0' into
72     -- RCS_VERSION)
73 
74     update ad_feature_versions
75     set filename = l_actual_filename,
76         rcs_version = l_actual_rcs_version
77     where filename = p_feature_name;
78 
79     -- Bug 2890523: Also update feature version if needed.
80     -- That is, if p_db_version is also greater than the one in the database,
81     -- then update it.
82 
83     -- Note: Dont touch ENABLED_FLAG.
84 
85     update ad_feature_versions
86     set current_db_version = p_db_version,
87         last_update_date = sysdate
88     where feature_name = p_feature_name
89     and p_db_version > current_db_version;
90 
91     commit;
92 
93     return;
94 
95   end if;
96 
97   if not ad_patch.compare_versions(l_actual_rcs_version, l_curr_rcs_version)
98   then
99 
100     -- l_actual_rcs_version is newer. Lets update.
101 
102     -- Note: (1) Dont touch ENABLED_FLAG.
103     --       (2) Intentionally keep these as 2 separate UPDATE's, bcoz their
104     --           WHERE clauses are a bit different. (Intentionally keeping
105     --           the WHERE clause of the first update stmt (the RCS_VERSION
106     --           one) as just a simple one on FEATURE_NAME, bcoz this column
107     --           serves as just a parallel "checkfile" infrastructure. See
108     --           bug 2899475 for details)
109     --       (3) Leapfrogging not supported (ie. if a lower file version has
110     --           a higher feature version, the feature version wouldn't get
111     --           updated)
112 
113     update ad_feature_versions
114     set rcs_version = l_actual_rcs_version,
115         last_update_date = sysdate
116     where feature_name = p_feature_name;
117 
118 
119     -- Next, update the feature version if thats also newer.
120 
121     update ad_feature_versions
122     set current_db_version = p_db_version,
123         last_update_date = sysdate
124     where feature_name = p_feature_name
125     and p_db_version > current_db_version;
126 
127   end if;
128 
129   commit;
130 
131 exception when no_data_found then
132   insert into ad_feature_versions
133   (
134     feature_name, current_db_version, enabled_flag,
135     filename, rcs_version,
136     creation_date,last_update_date
137   )
138   values
139   (
140     p_feature_name, p_db_version, p_enabled_flag,
141     l_actual_filename, l_actual_rcs_version,
142     sysdate, sysdate
143   );
144 
145   commit;
146 
147 end load_row;
148 
149 
150 end ad_feature_vers_pkg;