DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_API_HOOK_INTERNAL

Source


1 Package Body hr_api_hook_internal as
2 /* $Header: peahkbsi.pkb 115.1 2002/12/03 16:24:43 apholt ship $ */
3 --
4 -- Package Variables
5 --
6 g_package  varchar2(33) := '  hr_api_hook_internal.';
7 --
8 -- ------------------------------------------------------------------------
9 -- |--------------------------< create_api_hook >----------------------------|
10 -- ------------------------------------------------------------------------
11 --
12 procedure create_api_hook
13   (p_validate                     in     boolean  default false,
14    p_effective_date               in     date,
15    p_api_module_id                in     number,
16    p_api_hook_type                in     varchar2,
17    p_hook_package                 in     varchar2,
18    p_hook_procedure               in     varchar2,
19    p_legislation_code             in     varchar2         default null,
20    p_legislation_package          in     varchar2         default null,
21    p_legislation_function         in     varchar2         default null,
22    p_api_hook_id                  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_id                hr_api_hooks.api_hook_id%TYPE;
31   l_proc                       varchar2(72) := g_package||'create_api_hook';
32   --
33   --
34   -- Declare a cursor that will check whether the passed
35   -- in hook package and hook procedure form a unique combination
36      cursor csr_valid_combo is
37      select api_hook_id from hr_api_hooks hah
38      where hah.hook_package = p_hook_package
39      and   hah.hook_procedure = p_hook_procedure;
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;
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      open csr_valid_combo;
63      fetch csr_valid_combo into l_api_hook_id;
64 
65   -- If the module does not exist then create it.
66   -- Do not error if the module does exist, simply return.
67   --
68      if csr_valid_combo%notfound then
69       --
70       -- Insert the hook row.
71       --
72       hr_ahk_ins.ins
73       (
74       p_api_hook_id                  =>  l_api_hook_id,
75       p_effective_date               =>  l_effective_date,
76       p_api_module_id                =>  p_api_module_id,
77       p_api_hook_type                =>  p_api_hook_type,
78       p_hook_package                 =>  p_hook_package,
79       p_hook_procedure               =>  p_hook_procedure,
80       p_legislation_code             =>  p_legislation_code,
81       p_legislation_package          =>  p_legislation_package,
82       p_legislation_function         =>  p_legislation_function
83       );
84       --
85      end if;
86 
87   close csr_valid_combo;
88   --
89   hr_utility.set_location(l_proc, 20);
90   --
91   -- When in validation only mode raise the Validate_Enabled exception
92   --
93   if p_validate then
94     raise hr_api.validate_enabled;
95   end if;
96   --
97   -- Set all output arguments
98   --
99   p_api_hook_id := l_api_hook_id;
100   --
101   hr_utility.set_location(' Leaving:'||l_proc, 100);
102 exception
103   when hr_api.validate_enabled then
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_id  := null;
110     --
111     -- As the Validate_Enabled exception has been raised
112     -- we must rollback to the savepoint
113     --
114     ROLLBACK TO create_api_hook;
115     --
116   when others then
117     ROLLBACK TO create_api_hook;
118     p_api_hook_id  := null;
119     RAISE;
120 end create_api_hook;
121 --
122 -- ------------------------------------------------------------------------
123 -- |--------------------------< delete_api_hook >----------------------------|
124 -- ------------------------------------------------------------------------
125 --
126 procedure delete_api_hook
127   (p_validate                      in      boolean  default false,
128    p_api_hook_id                   in     number)  is
129   --
130   l_proc                       varchar2(72) := g_package||'delete_api_hook';
131   --
132 begin
133   hr_utility.set_location('Entering:'|| l_proc, 5);
134   --
135   -- Issue a savepoint if operating in validation only mode.
136   --
137   if p_validate then
138     savepoint delete_api_hook;
139   end if;
140   --
141   hr_utility.set_location(l_proc, 10);
142   --
143   -- Validation in addition to Table Handlers
144   --
145   -- None required.
146   --
147   -- Process Logic
148   --
149     hr_ahk_del.del
150       (p_api_hook_id                => p_api_hook_id);
151   --
152   hr_utility.set_location(l_proc, 20);
153   --
154   -- When in validation only mode raise the Validate_Enabled exception
155   --
156   if p_validate then
157     raise hr_api.validate_enabled;
158   end if;
159   --
160   hr_utility.set_location(' Leaving:'||l_proc, 100);
161 exception
162   when hr_api.validate_enabled then
163     --
164     -- As the Validate_Enabled exception has been raised
165     -- we must rollback to the savepoint
166     --
167     ROLLBACK TO delete_api_hook;
168     --
169 end delete_api_hook;
170 --
171 -- ------------------------------------------------------------------------
172 -- |--------------------------< update_api_hook >----------------------------|
173 -- ------------------------------------------------------------------------
174 --
175 procedure update_api_hook
176   (p_validate                     in     boolean      default false,
177    p_effective_date               in     date,
178    p_api_hook_id                  in     number,
179    p_api_hook_type                in     varchar2     default hr_api.g_varchar2,
180    p_hook_package                 in     varchar2     default hr_api.g_varchar2,
181    p_hook_procedure               in     varchar2     default hr_api.g_varchar2,
182    p_legislation_package          in     varchar2     default hr_api.g_varchar2,
183    p_legislation_function         in     varchar2     default hr_api.g_varchar2
184   )
185 is
186   --
187   -- Declare cursors and local variables
188   --
189   l_effective_date      date;
190   --
191   -- Out variables
192   --
193   l_api_hook_id                hr_api_hooks.api_hook_id%TYPE;
194   --
195   l_proc                       varchar2(72) := g_package||'update_api_hook';
196   --
197 begin
198   hr_utility.set_location('Entering:'|| l_proc, 5);
199   --
200   -- Set l_effective_date equal to truncated version of p_effective_date for
201   -- API work. Stops dates being passed to row handlers with time portion.
202   --
203   l_effective_date := trunc(p_effective_date);
204   --
205   -- Issue a savepoint if operating in validation only mode.
206   --
207   if p_validate then
208     savepoint update_api_hook;
209   end if;
210   --
211   hr_utility.set_location(l_proc, 10);
212   --
213   -- Validation in addition to Table Handlers
214   --
215   -- Update the hook row.
216   --
217   hr_ahk_upd.upd
218     (p_api_hook_id                  =>  p_api_hook_id,
219      p_effective_date               =>  l_effective_date,
220      p_api_hook_type                =>  p_api_hook_type,
221      p_hook_package                 =>  p_hook_package,
222      p_hook_procedure               =>  p_hook_procedure,
223      p_legislation_package          =>  p_legislation_package,
224      p_legislation_function         =>  p_legislation_function
225     );
226   --
227   hr_utility.set_location(l_proc, 20);
228   --
229   -- When in validation only mode raise the Validate_Enabled exception
230   --
231   if p_validate then
232     raise hr_api.validate_enabled;
233   end if;
234   --
235   -- Set all output arguments
236   --
237   hr_utility.set_location(' Leaving:'||l_proc, 100);
238 exception
239   when hr_api.validate_enabled then
240     --
241     -- As the Validate_Enabled exception has been raised
242     -- we must rollback to the savepoint
243     --
244     ROLLBACK TO update_api_hook;
245     --
246 end update_api_hook;
247 --
248 end hr_api_hook_internal;