DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_API_HOOK_CALL_API

Source


1 Package Body hr_api_hook_call_api as
2 /* $Header: peahcapi.pkb 120.1 2007/08/20 10:34:44 ande ship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_api_hook_call.';
7 --
8 -- ------------------------------------------------------------------------
9 -- |---------------------< create_api_hook_call >-------------------------|
10 -- ------------------------------------------------------------------------
11 --
12 procedure create_api_hook_call
13   (p_validate                     in     boolean  default false,
14    p_effective_date               in     date,
15    p_api_hook_id                  in     number,
16    p_api_hook_call_type           in     varchar2,
17    p_sequence                     in     number,
18    p_enabled_flag                 in     varchar2,
19    p_call_package                 in     varchar2  default null,
20    p_call_procedure               in     varchar2  default null,
21    p_api_hook_call_id             out nocopy    number,
22    p_object_version_number        out nocopy    number) is
23   --
24   -- Declare cursors and local variables
25   --
26   l_effective_date      date;
27   --
28   -- Out variables
29   --
30   l_api_hook_call_id           hr_api_hook_calls.api_hook_call_id%TYPE;
31   l_object_version_number      hr_api_hook_calls.object_version_number%TYPE;
32 
33 -- Temp variables
34   l_encoded_error              hr_api_hook_calls.encoded_error%TYPE := null;
35   l_status                     hr_api_hook_calls.status%TYPE := 'N';
36   l_pre_processor_date         hr_api_hook_calls.pre_processor_date%TYPE := null;
37   l_legislation_code           hr_api_hook_calls.legislation_code%TYPE := null;
38   --
39   l_proc                       varchar2(72) := g_package||'create_api_hook_call';
40   --
41 begin
42   hr_utility.set_location('Entering:'|| l_proc, 5);
43   --
44   -- Set l_effective_date equal to truncated version of p_effective_date for
45   -- API work. Stops dates being passed to row handlers with time portion.
46   --
47   l_effective_date := trunc(p_effective_date);
48   --
49   -- Issue a savepoint if operating in validation only mode.
50   --
51   if p_validate then
52     savepoint create_api_hook_call;
53   end if;
54   --
55   hr_utility.set_location(l_proc, 10);
56   --
57   -- Validation in addition to Table Handlers
58   --
59   -- None required.
60   --
61   -- Process Logic
62   --
63   -- Insert the hook row.
64   --
65 
66   hr_ahc_ins.ins
67   (
68   p_api_hook_call_id             => l_api_hook_call_id ,
69   p_effective_date               => l_effective_date,
70   p_api_hook_id                  => p_api_hook_id,
71   p_api_hook_call_type           => p_api_hook_call_type,
72   p_legislation_code             => l_legislation_code,
73   p_sequence                     => p_sequence,
74   p_enabled_flag                 => p_enabled_flag,
75   p_call_package                 => p_call_package,
76   p_call_procedure               => p_call_procedure,
77   p_pre_processor_date           => l_pre_processor_date,
78   p_encoded_error                => l_encoded_error,
79   p_status                       => l_status,
80   p_object_version_number        => l_object_version_number
81   );
82   --
83   hr_utility.set_location(l_proc, 20);
84   --
85   -- When in validation only mode raise the Validate_Enabled exception
86   --
87   if p_validate then
88     raise hr_api.validate_enabled;
89   end if;
90   --
91   -- Set all output arguments
92   --
93   p_api_hook_call_id := l_api_hook_call_id;
94   p_object_version_number := l_object_version_number;
95   --
96   hr_utility.set_location(' Leaving:'||l_proc, 100);
97 exception
98   when hr_api.validate_enabled then
99     --
100     -- As the Validate_Enabled exception has been raised
101     -- we must rollback to the savepoint
102     --
103     ROLLBACK TO create_api_hook_call;
104     --
105     -- Only set output warning arguments
106     -- (Any key or derived arguments must be set to null
107     -- when validation only mode is being used.)
108     --
109     p_api_hook_call_id  := null;
110     p_object_version_number := null;
111     --
112   WHEN others then
113     --added as part of
114     --NOCOPY Performance Changes for 11.5.9
115     ROLLBACK TO create_api_hook_call;
116      p_object_version_number :=null;
117     p_api_hook_call_id  := null;
118     --
119 end create_api_hook_call;
120 --
121 -- ---------------------------------------------------------------------------
122 -- |--------------------------< delete_api_hook_call >-------------------|
123 -- ---------------------------------------------------------------------------
124 --
125 procedure delete_api_hook_call
126   (p_validate                           in     boolean  default false,
127    p_api_hook_call_id                   in     number,
128    p_object_version_number              in     number
129   )  is
130   --
131   l_proc                   varchar2(72) := g_package||'delete_api_hook_call';
132   l_leg_code               hr_api_hook_calls.legislation_code%TYPE;
133   --
134   -- Setup a cursor to retrieve leg code for the hook call
135   --
136      Cursor csr_get_leg_code is
137      Select legislation_code
138      from   hr_api_hook_calls
139      where api_hook_call_id = p_api_hook_call_id;
140 
141 begin
142   hr_utility.set_location('Entering:'|| l_proc, 5);
143   --
144   -- Issue a savepoint if operating in validation only mode.
145   --
146   if p_validate then
147     savepoint delete_api_hook_call;
148   end if;
149   --
150   hr_utility.set_location(l_proc, 10);
151   --
152   -- Validation in addition to Table Handlers
153   --
154      open csr_get_leg_code;
155      fetch csr_get_leg_code into l_leg_code;
156 
157      if (l_leg_code is not null) then
158         hr_utility.set_message(800, 'PER_52149_AHC_CANNOT_DEL_ROW');
159         hr_utility.raise_error;
160      end if;
161   --
162   -- Process Logic
163   --
164     hr_ahc_del.del
165       (p_api_hook_call_id                => p_api_hook_call_id,
166        p_object_version_number           => p_object_version_number);
167   --
168   hr_utility.set_location(l_proc, 20);
169   --
170   -- When in validation only mode raise the Validate_Enabled exception
171   --
172   if p_validate then
173     raise hr_api.validate_enabled;
174   end if;
175   --
176   hr_utility.set_location(' Leaving:'||l_proc, 100);
177 exception
178   when hr_api.validate_enabled then
179     --
180     -- As the Validate_Enabled exception has been raised
181     -- we must rollback to the savepoint
182     --
183     ROLLBACK TO delete_api_hook_call;
184 end delete_api_hook_call;
185 --
186 -- ------------------------------------------------------------------------
187 -- |---------------------< update_api_hook_call >-------------------------|
188 -- ------------------------------------------------------------------------
189 --
190 procedure update_api_hook_call
191   (p_validate                     in     boolean  default false,
192    p_effective_date               in     date,
193    p_api_hook_call_id             in     number,
194    p_sequence                     in     number    default hr_api.g_number,
195    p_enabled_flag                 in     varchar2  default hr_api.g_varchar2,
196    p_call_package                 in     varchar2  default hr_api.g_varchar2,
197    p_call_procedure               in     varchar2  default hr_api.g_varchar2,
198    p_object_version_number        in out nocopy    number
199   ) is
200   --
201   l_proc                   varchar2(72) := g_package||'update_api_hook_call';
202   --
203   -- Declare cursors and local variables
204   --
205   l_effective_date        date;
206   --
207   l_object_version_number number;
208   --
209   l_leg_code               hr_api_hook_calls.legislation_code%TYPE;
210   --
211   -- Setup a cursor to retrieve leg code for the hook call
212   --
213      Cursor csr_get_leg_code is
214      Select legislation_code
215      from   hr_api_hook_calls
216      where api_hook_call_id = p_api_hook_call_id;
217   --
218 begin
219   hr_utility.set_location('Entering:'|| l_proc, 5);
220   --
221   -- Set l_effective_date equal to truncated version of p_effective_date for
222   -- API work. Stops dates being passed to row handlers with time portion.
223   --
224   l_effective_date := trunc(p_effective_date);
225   --
226   -- Capture the IN value for OVN
227   --
228   l_object_version_number := p_object_version_number;
229   --
230   -- Issue a savepoint if operating in validation only mode.
231   --
232   if p_validate then
233     savepoint update_api_hook_call;
234   end if;
235   --
236   hr_utility.set_location(l_proc, 10);
237   --
238   -- Validation in addition to Table Handlers
239   --
240   open csr_get_leg_code;
241   fetch csr_get_leg_code into l_leg_code;
242   if (l_leg_code is not null) then
243      --
244      close csr_get_leg_code;
245      hr_utility.set_message(800, 'PER_52149_AHC_CANNOT_DEL_ROW');
246      hr_utility.raise_error;
247      --
248   end if;
249   close csr_get_leg_code;
250   --
251   -- Update the hook row.
252   --
253   hr_ahc_upd.upd
254     (p_api_hook_call_id             => p_api_hook_call_id
255     ,p_effective_date               => l_effective_date
256     ,p_sequence                     => p_sequence
257     ,p_enabled_flag                 => p_enabled_flag
258     ,p_call_package                 => p_call_package
259     ,p_call_procedure               => p_call_procedure
260     ,p_object_version_number        => p_object_version_number
261     );
262   --
263   hr_utility.set_location(l_proc, 20);
264   --
265   -- When in validation only mode raise the Validate_Enabled exception
266   --
267   if p_validate then
268     raise hr_api.validate_enabled;
269   end if;
270   --
271   hr_utility.set_location(' Leaving:'||l_proc, 100);
272 exception
273   when hr_api.validate_enabled then
274     --
275     -- Only set output warning arguments
276     -- (Any key or derived arguments must be set to null
277     -- when validation only mode is being used.)
278     --
279     p_object_version_number := l_object_version_number;
280     --
281     -- As the Validate_Enabled exception has been raised
282     -- we must rollback to the savepoint
283     --
284     ROLLBACK TO update_api_hook_call;
285     --
286   WHEN others then
287     --added as part of
288     --NOCOPY Performance Changes for 11.5.9
289     ROLLBACK TO update_api_hook_call;
290      p_object_version_number :=null;
291     --
292 end update_api_hook_call;
293 --
294 --
295 end hr_api_hook_call_api;