DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_CONFIG_VAR_API

Source


1 Package Body AME_CONFIG_VAR_API as
2 /* $Header: amcfvapi.pkb 120.0 2005/09/02 03:54 mbocutt noship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := 'AME_CONFIG_VAR_API';
7 --
8 -- ----------------------------------------------------------------------------
9 -- |--------------------<UPDATE_AME_CONFIG_VARIABLE>--------------------------|
10 -- ----------------------------------------------------------------------------
11 --
12 procedure update_ame_config_variable
13   (p_validate                    in     boolean   default false
14   ,p_application_id              in     number
15   ,p_variable_name               in     varchar2
16   ,p_variable_value              in     varchar2  default hr_api.g_varchar2
17   ,p_object_version_number       in out nocopy   number
18   ,p_start_date                     out nocopy   date
19   ,p_end_date                       out nocopy   date
20   ) is
21   --
22   -- Declare cursors and local variables
23   --
24   cursor csr_isAlreadyDefined is
25     select 'Y'
26       from ame_config_vars
27      where application_id = p_application_id
28        and variable_name  = p_variable_name
29        and sysdate between start_date and
30              nvl(end_date - ame_util.oneSecond, sysdate);
31   l_proc                      varchar2(72) := g_package||'update_ame_config_variable';
32   l_object_version_number     number;
33   l_start_date                date;
34   l_end_date                  date;
35   l_key                       varchar2(1);
36   --
37   begin
38     hr_utility.set_location('Entering:'|| l_proc, 10);
39     --
40     -- Issue a savepoint
41     --
42     savepoint update_ame_config_variable;
43     --
44     -- Remember IN OUT parameter IN values
45     --
46     l_object_version_number := p_object_version_number;
47     --
48     -- Call Before Process User Hook
49     --
50     begin
51       ame_config_var_bk1.update_ame_config_variable_b
52         (p_application_id        => p_application_id
53         ,p_variable_name         => p_variable_name
54         ,p_variable_value        => p_variable_value
55         ,p_object_version_number => p_object_version_number
56         );
57     exception
58       when hr_api.cannot_find_prog_unit then
59         hr_api.cannot_find_prog_unit_error
60                               (p_module_name => 'update_ame_config_variable'
61                               ,p_hook_type   => 'BP'
62                               );
63     end;
64     --
65     -- Process Logic. Determine whether its an 'insert' or 'update' process.
66     --
67     open csr_isAlreadyDefined;
68     fetch csr_isAlreadyDefined into l_key;
69     if(csr_isAlreadyDefined%notfound) then
70       ame_cfv_ins.ins(p_effective_date        => sysdate
71                      ,p_application_id        => p_application_id
72                      ,p_variable_name         => p_variable_name
73                      ,p_variable_value        => p_variable_value
74                      ,p_security_group_id     => null
75                      ,p_object_version_number => p_object_version_number
76                      ,p_start_date            => l_start_date
77                      ,p_end_date              => l_end_date
78                      );
79     else
80       ame_cfv_upd.upd(p_effective_date        => sysdate
81                      ,p_datetrack_mode        => hr_api.g_update
82                      ,p_application_id        => p_application_id
83                      ,p_variable_name         => p_variable_name
84                      ,p_variable_value        => p_variable_value
85                      ,p_security_group_id     => null
86                      ,p_object_version_number => p_object_version_number
87                      ,p_start_date            => l_start_date
88                      ,p_end_date              => l_end_date
89                      );
90     end if;
91     close csr_isAlreadyDefined;
92     --
93     -- Call After Process User Hook
94     --
95     begin
96       ame_config_var_bk1.update_ame_config_variable_a
97         (p_application_id        => p_application_id
98         ,p_variable_name         => p_variable_name
99         ,p_variable_value        => p_variable_value
100         ,p_object_version_number => p_object_version_number
101         ,p_start_date            => l_start_date
102         ,p_end_date              => l_end_date
103         );
104     exception
105       when hr_api.cannot_find_prog_unit then
106         hr_api.cannot_find_prog_unit_error
107                               (p_module_name => 'update_ame_config_variable'
108                               ,p_hook_type   => 'AP'
109                               );
110     end;
111     --
112     -- When in validation only mode raise the Validate_Enabled exception
113     --
114     if p_validate then
115       raise hr_api.validate_enabled;
116     end if;
117     --
118     -- Set all IN OUT and OUT parameters with out values.
119     --
120     p_start_date   := l_start_date;
121     p_end_date     := l_end_date;
122     --
123     hr_utility.set_location(' Leaving:'||l_proc, 70);
124   exception
125     when hr_api.validate_enabled then
126       --
127       -- As the Validate_Enabled exception has been raised
128       -- we must rollback to the savepoint
129       --
130       rollback to update_ame_config_variable;
131       --
132       -- Reset IN OUT parameters and set OUT parameters
133       -- (Any key or derived arguments must be set to null
134       -- when validation only mode is being used.)
135       --
136       p_object_version_number  := l_object_version_number;
137       p_start_date             := null;
138       p_end_date               := null;
139       --
140       hr_utility.set_location(' Leaving:'||l_proc, 80);
141     when others then
142       --
143       -- A validation or unexpected error has occured
144       --
145       rollback to update_ame_config_variable;
146       --
147       -- Reset IN OUT parameters and set all
148       -- OUT parameters, including warnings, to null
149       --
150       p_object_version_number  := l_object_version_number;
151       p_start_date             := null;
152       p_end_date               := null;
153       --
154       hr_utility.set_location(' Leaving:'||l_proc, 90);
155       raise;
156   end update_ame_config_variable;
157 --
158 --
159 -- ----------------------------------------------------------------------------
160 -- |-----------------< DELETE_AME_CONFIG_VARIABLE >---------------------------|
161 -- ----------------------------------------------------------------------------
162 --
163 procedure delete_ame_config_variable
164   (p_validate              in     boolean  default false
165   ,p_application_id        in     number
166   ,p_variable_name         in     varchar2
167   ,p_object_version_number in out nocopy   number
168   ,p_start_date               out nocopy   date
169   ,p_end_date                 out nocopy   date
170   ) is
171   --
172   -- Declare cursors and local variables
173   --
174   l_proc                   varchar2(72) := g_package||'delete_ame_config_variable';
175   l_object_version_number  number;
176   l_start_date             date;
177   l_end_date               date;
178   --
179   begin
180     hr_utility.set_location('Entering:'|| l_proc, 10);
181     --
182     -- Issue a savepoint
183     --
184     savepoint delete_ame_config_variable;
185     --
186     -- Remember IN OUT parameter IN values
187     --
188     l_object_version_number := p_object_version_number;
189     --
190     -- Call Before Process User Hook
191     --
192     begin
193       ame_config_var_bk2.delete_ame_config_variable_b
194         (p_application_id           => p_application_id
195         ,p_variable_name            => p_variable_name
196         ,p_object_version_number    => p_object_version_number
197         );
198     exception
199       when hr_api.cannot_find_prog_unit then
200         hr_api.cannot_find_prog_unit_error
201                               (p_module_name => 'delete_ame_config_variable'
202                               ,p_hook_type   => 'BP'
203                               );
204     end;
205     --
206     -- Process Logic
207     --
208     ame_cfv_del.del(p_effective_date          => sysdate
209                    ,p_datetrack_mode          => hr_api.g_delete
210                    ,p_application_id          => p_application_id
211                    ,p_variable_name           => p_variable_name
212                    ,p_object_version_number   => p_object_version_number
213                    ,p_start_date              => l_start_date
214                    ,p_end_date                => l_end_date
215                    );
216     --
217     -- Call After Process User Hook
218     --
219     begin
220       ame_config_var_bk2.delete_ame_config_variable_a
221       (p_application_id          => p_application_id
222       ,p_variable_name           => p_variable_name
223       ,p_object_version_number   => p_object_version_number
224       ,p_start_date              => l_start_date
225       ,p_end_date                => l_end_date
226       );
227     exception
228       when hr_api.cannot_find_prog_unit then
229         hr_api.cannot_find_prog_unit_error
230                               (p_module_name => 'delete_ame_config_variable'
231                               ,p_hook_type   => 'AP'
232                               );
233     end;
234     --
235     -- When in validation only mode raise the Validate_Enabled exception
236     --
237     if p_validate then
238       raise hr_api.validate_enabled;
239     end if;
240     --
241     -- Set all IN OUT and OUT parameters with out values.
242     --
243     p_start_date  := l_start_date;
244     p_end_date    := l_end_date;
245     --
246     hr_utility.set_location(' Leaving:'||l_proc, 70);
247   exception
248     when hr_api.validate_enabled then
249       --
250       -- As the Validate_Enabled exception has been raised
251       -- we must rollback to the savepoint
252       --
253       rollback to delete_ame_config_variable;
254       --
255       -- Reset IN OUT parameters and set OUT parameters
256       -- (Any key or derived arguments must be set to null
257       -- when validation only mode is being used.)
258       --
259       p_object_version_number := l_object_version_number;
260       p_start_date            := null;
261       p_end_date              := null;
262       --
263       hr_utility.set_location(' Leaving:'||l_proc, 80);
264     when others then
265       --
266       -- A validation or unexpected error has occured
267       --
268       rollback to delete_ame_config_variable;
269       --
270       -- Reset IN OUT parameters and set all
271       -- OUT parameters, including warnings, to null
272       --
273       p_object_version_number := l_object_version_number;
274       p_start_date            := null;
275       p_end_date              := null;
276       --
277       hr_utility.set_location(' Leaving:'||l_proc, 90);
278       raise;
279   end delete_ame_config_variable;
280 end AME_CONFIG_VAR_API;