[Home] [Help]
PACKAGE BODY: APPS.HXC_RETRIEVAL_RULE_GRP_API
Source
1 Package Body hxc_retrieval_rule_grp_api as
2 /* $Header: hxcrrgapi.pkb 120.2 2005/09/23 06:20:31 nissharm noship $ */
3 --
4 -- Package Variables
5 --
6 g_package varchar2(33) := ' hxc_retrieval_rule_grp_api.';
7
8 g_entity_type varchar2(16) := 'RETRIEVAL_RULES';
9
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |-----------------------< create_retrieval_rule_grp >------------------------|
14 -- ----------------------------------------------------------------------------
15 --
16 procedure create_retrieval_rule_grp
17 (p_validate in boolean default false
18 ,p_retrieval_rule_grp_id in out nocopy number
19 ,p_object_version_number in out nocopy number
20 ,p_name in varchar2
21 ) is
22 --
23 -- Declare cursors and local variables
24 --
25 l_proc varchar2(72);
26 l_object_version_number hxc_entity_groups.object_version_number%TYPE;
27 l_retrieval_rule_grp_id hxc_entity_groups.entity_group_id%TYPE;
28 --
29 begin
30 g_debug := hr_utility.debug_enabled;
31 --
32
33 --
34 if g_debug then
35 l_proc := g_package||' create_retrieval_rule_grp';
36 hr_utility.set_location('Entering:'|| l_proc, 10);
37 end if;
38 --
39 -- Issue a savepoint if operating in validation only mode
40 --
41 savepoint create_retrieval_rule_grp;
42 --
43 hxc_retrieval_rule_grp_api.chk_name
44 ( p_name => p_name
45 , p_entity_group_id => p_retrieval_rule_grp_id );
46
47 if g_debug then
48 hr_utility.set_location(l_proc, 20);
49 end if;
50 --
51 -- Call Before Process User Hook
52 --
53 begin
54 hxc_retrieval_rule_grp_BK_1.create_retrieval_rule_grp_b
55 (p_retrieval_rule_grp_id => p_retrieval_rule_grp_id
56 ,p_object_version_number => p_object_version_number
57 ,p_name => p_name
58 );
59 exception
60 when hr_api.cannot_find_prog_unit then
61 hr_api.cannot_find_prog_unit_error
62 (p_module_name => 'create_retrieval_rule_grp'
63 ,p_hook_type => 'BP'
64 );
65 end;
66 --
67 if g_debug then
68 hr_utility.set_location(l_proc, 30);
69 end if;
70 --
71 -- Process Logic
72 --
73 --
74 if g_debug then
75 hr_utility.set_location(l_proc, 40);
76 end if;
77 --
78 -- call row handler
79 --
80 hxc_heg_ins.ins (
81 p_name => p_name
82 ,p_entity_type => g_entity_type
83 ,p_entity_group_id => l_retrieval_rule_grp_id
84 ,p_object_version_number => l_object_version_number );
85 --
86 if g_debug then
87 hr_utility.set_location(l_proc, 50);
88 end if;
89 --
90 -- Call After Process User Hook
91 --
92 begin
93 hxc_retrieval_rule_grp_BK_1.create_retrieval_rule_grp_a
94 (p_retrieval_rule_grp_id => l_retrieval_rule_grp_id
95 ,p_object_version_number => l_object_version_number
96 ,p_name => p_name
97 );
98 exception
99 when hr_api.cannot_find_prog_unit then
100 hr_api.cannot_find_prog_unit_error
101 (p_module_name => 'create_retrieval_rule_grp'
102 ,p_hook_type => 'AP'
103 );
104 end;
105 --
106 if g_debug then
107 hr_utility.set_location(l_proc, 60);
108 end if;
109 --
110 -- When in validation only mode raise the Validate_Enabled exception
111 --
112 if p_validate then
113 raise hr_api.validate_enabled;
114 end if;
115 --
116 if g_debug then
117 hr_utility.set_location(' Leaving:'||l_proc, 70);
118 end if;
119 --
120 -- Set all output arguments
121 --
122 p_retrieval_rule_grp_id := l_retrieval_rule_grp_id;
123 p_object_version_number := l_object_version_number;
124 --
125 exception
126 --
127 when hr_api.validate_enabled then
128 --
129 -- As the Validate_Enabled exception has been raised
130 -- we must rollback to the savepoint
131 --
132 ROLLBACK TO create_retrieval_rule_grp;
133 --
134 -- Only set output warning arguments
135 -- (Any key or derived arguments must be set to null
136 -- when validation only mode is being used.)
137 --
138 p_retrieval_rule_grp_id := null;
139 p_object_version_number := null;
140 --
141 if g_debug then
142 hr_utility.set_location(' Leaving:'||l_proc, 80);
143 end if;
144 --
145 when others then
146 --
147 -- A validation or unexpected error has occured
148 --
149 if g_debug then
150 hr_utility.trace('In exeception');
151 end if;
152 ROLLBACK TO create_retrieval_rule_grp;
153 raise;
154 --
155 END create_retrieval_rule_grp;
156 --
157 -- ----------------------------------------------------------------------------
158 -- |-------------------< update_retrieval_rule_grp>-----------------------------|
159 -- ----------------------------------------------------------------------------
160 --
161 procedure update_retrieval_rule_grp
162 (p_validate in boolean default false
163 ,p_retrieval_rule_grp_id in number
164 ,p_object_version_number in out nocopy number
165 ,p_name in varchar2
166 ) is
167 --
168 -- Declare cursors and local variables
169 --
170 l_proc varchar2(72);
171 l_object_version_number hxc_entity_groups.object_version_number%TYPE := p_object_version_number;
172 --
173 begin
174 g_debug := hr_utility.debug_enabled;
175 --
176 if g_debug then
177 l_proc := g_package||' update_retrieval_rule_grp';
178 hr_utility.set_location('Entering:'|| l_proc, 10);
179 end if;
180 --
181 -- Issue a savepoint if operating in validation only mode
182 --
183 savepoint update_retrieval_rule_grp;
184 --
185 hxc_retrieval_rule_grp_api.chk_name
186 ( p_name => p_name
187 , p_entity_group_id => p_retrieval_rule_grp_id );
188
189 if g_debug then
190 hr_utility.set_location(l_proc, 20);
191 end if;
192 --
193 -- Call Before Process User Hook
194 --
195 begin
196 hxc_retrieval_rule_grp_BK_2.update_retrieval_rule_grp_b
197 (p_retrieval_rule_grp_id => p_retrieval_rule_grp_id
198 ,p_object_version_number => p_object_version_number
199 ,p_name => p_name
200 );
201 exception
202 when hr_api.cannot_find_prog_unit then
203 hr_api.cannot_find_prog_unit_error
204 (p_module_name => 'update_retrieval_rule_grp'
205 ,p_hook_type => 'BP'
206 );
207 end;
208 --
209 if g_debug then
210 hr_utility.set_location(l_proc, 30);
211 end if;
212 --
213 -- Process Logic
214 --
215 -- call row handler
216 --
217 hxc_heg_upd.upd (
218 p_name => p_name
219 ,p_entity_type => g_entity_type
220 ,p_entity_group_id => p_retrieval_rule_grp_id
221 ,p_object_version_number => l_object_version_number );
222 --
223 --
224 if g_debug then
225 hr_utility.set_location(l_proc, 40);
226 end if;
227 --
228 -- Call After Process User Hook
229 --
230 begin
231 hxc_retrieval_rule_grp_BK_2.update_retrieval_rule_grp_a
232 (p_retrieval_rule_grp_id => p_retrieval_rule_grp_id
233 ,p_object_version_number => l_object_version_number
234 ,p_name => p_name
235 );
236 exception
237 when hr_api.cannot_find_prog_unit then
238 hr_api.cannot_find_prog_unit_error
239 (p_module_name => 'update_retrieval_rule_grp'
240 ,p_hook_type => 'AP'
241 );
242 end;
243 --
244 if g_debug then
245 hr_utility.set_location(l_proc, 50);
246 end if;
247 --
248 -- When in validation only mode raise the Validate_Enabled exception
249 --
250 if p_validate then
251 raise hr_api.validate_enabled;
252 end if;
253 --
254 if g_debug then
255 hr_utility.set_location(' Leaving:'||l_proc, 60);
256 end if;
257 --
258 -- Set all output arguments
259 --
260 p_object_version_number := l_object_version_number;
261 --
262 exception
263 --
264 when hr_api.validate_enabled then
265 --
266 -- As the Validate_Enabled exception has been raised
267 -- we must rollback to the savepoint
268 --
269 ROLLBACK TO update_retrieval_rule_grp;
270 --
271 -- Only set output warning arguments
272 -- (Any key or derived arguments must be set to null
273 -- when validation only mode is being used.)
274 --
275 p_object_version_number := null;
276 --
277 if g_debug then
278 hr_utility.set_location(' Leaving:'||l_proc, 60);
279 end if;
280 --
281 when others then
282 --
283 -- A validation or unexpected error has occured
284 --
285 if g_debug then
286 hr_utility.trace('In exeception');
287 end if;
288 ROLLBACK TO update_retrieval_rule_grp;
289 raise;
290 --
291 END update_retrieval_rule_grp;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |----------------------< delete_retrieval_rule_grp >-------------------------|
295 -- ----------------------------------------------------------------------------
296 --
297 procedure delete_retrieval_rule_grp
298 (p_validate in boolean default false
299 ,p_retrieval_rule_grp_id in number
300 ,p_object_version_number in number
301 ) is
302 --
303 -- Declare cursors and local variables
304 --
305 l_proc varchar2(72);
306 --
307 begin
308 g_debug := hr_utility.debug_enabled;
309 --
310
311 if g_debug then
312 l_proc := g_package||'delete_retrieval_rule_grp';
313 hr_utility.set_location('Entering:'|| l_proc, 10);
314 end if;
315 --
316 -- Issue a savepoint if operating in validation only mode
317 --
318 savepoint delete_retrieval_rule_grp;
319 --
320 chk_delete ( p_entity_group_id => p_retrieval_rule_grp_id );
321
322 if g_debug then
323 hr_utility.set_location(l_proc, 20);
324 end if;
325 --
326 -- Call Before Process User Hook
327 --
328 begin
329 --
330 hxc_retrieval_rule_grp_BK_3.delete_retrieval_rule_grp_b
331 (p_retrieval_rule_grp_id => p_retrieval_rule_grp_id
332 ,p_object_version_number => p_object_version_number
333 );
334 exception
335 when hr_api.cannot_find_prog_unit then
336 hr_api.cannot_find_prog_unit_error
337 (p_module_name => 'delete_retrieval_rule_grp_b'
338 ,p_hook_type => 'BP'
339 );
340 end;
341 --
342 if g_debug then
343 hr_utility.set_location(l_proc, 30);
344 end if;
345 --
346 -- Process Logic
347 --
348 hxc_heg_del.del
349 (
350 p_entity_group_id => p_retrieval_rule_grp_id
351 ,p_object_version_number => p_object_version_number
352 );
353 --
354 if g_debug then
355 hr_utility.set_location(l_proc, 40);
356 end if;
357 --
358 -- Call After Process User Hook
359 --
360 begin
361 --
362 hxc_retrieval_rule_grp_BK_3.delete_retrieval_rule_grp_a
363 (p_retrieval_rule_grp_id => p_retrieval_rule_grp_id
364 ,p_object_version_number => p_object_version_number
365 );
366 exception
367 when hr_api.cannot_find_prog_unit then
368 hr_api.cannot_find_prog_unit_error
369 (p_module_name => 'delete_retrieval_rule_grp_a'
370 ,p_hook_type => 'AP'
371 );
372 end;
373 --
374 -- When in validation only mode raise the Validate_Enabled exception
375 --
376 if p_validate then
377 raise hr_api.validate_enabled;
378 end if;
379 --
380 if g_debug then
381 hr_utility.set_location(' Leaving:'||l_proc, 50);
382 end if;
383 --
384 exception
385 --
386 when hr_api.validate_enabled then
387 --
388 -- As the Validate_Enabled exception has been raised
389 -- we must rollback to the savepoint
390 --
391 ROLLBACK TO delete_retrieval_rule_grp;
392 --
393 when others then
394 --
395 -- A validation or unexpected error has occured
396 --
397 ROLLBACK TO delete_retrieval_rule_grp;
398 raise;
399 --
400 end delete_retrieval_rule_grp;
401 --
402 --
403 -- ----------------------------------------------------------------------------
404 -- |-----------------------< chk_name >---------------------------------------|
405 -- ----------------------------------------------------------------------------
406 --
407 -- Description:
408 --
409 -- SEE DESCRIPTION IN PACKAGE HEADER
410 --
411 -- Note:
412 -- This procedure is called from the client
413 --
414 -- ----------------------------------------------------------------------------
415 Procedure chk_name
416 (
417 p_name in hxc_entity_groups.name%TYPE
418 ,p_entity_group_id in hxc_entity_groups.entity_group_id%TYPE
419 ) IS
420
421 l_proc varchar2(72);
422 --
423 -- cursor to check name is unique
424 --
425 CURSOR csr_chk_name IS
426 SELECT 'error'
427 FROM sys.dual
428 WHERE EXISTS (
429 SELECT 'x'
430 FROM hxc_entity_groups heg
431 WHERE heg.name = p_name
432 AND heg.entity_type = g_entity_type AND
433 ( heg.entity_group_id <> p_entity_group_id OR
434 p_entity_group_id IS NULL ) );
435 --
436 l_dup_name varchar2(5) := NULL;
437 --
438 BEGIN
439 g_debug := hr_utility.debug_enabled;
440
441 if g_debug then
442 l_proc := g_package||'chk_name';
443 hr_utility.set_location('Entering:'||l_proc, 5);
444 end if;
445 --
446 -- check that the name has been entered
447 --
448 IF ( p_name IS NULL )
449 THEN
450 --
451 hr_utility.set_message(809, 'HXC_HEG_RR_NAME_MAND');
452 hr_utility.raise_error;
453 --
454 END IF;
455 if g_debug then
456 hr_utility.set_location('Processing:'||l_proc, 10);
457 end if;
458 --
459 -- check that the name is unique
460 --
461 OPEN csr_chk_name;
462 FETCH csr_chk_name INTO l_dup_name;
463 CLOSE csr_chk_name;
464 --
465 IF ( l_dup_name IS NOT NULL )
466 THEN
467 --
468 hr_utility.set_message(809, 'HXC_HEG_RR_NAME_DUP');
469 hr_utility.raise_error;
470 --
471 END IF;
472 --
473 if g_debug then
474 hr_utility.set_location('Leaving:'||l_proc, 20);
475 end if;
476 --
477 END chk_name;
478 --
479 -- ----------------------------------------------------------------------------
480 -- |-----------------------< chk_delete >-------------------------------------|
481 -- ----------------------------------------------------------------------------
482 --
483 -- Description:
484 --
485 -- SEE DESCRIPTION IN PACKAGE HEADER
486 --
487 -- ----------------------------------------------------------------------------
488 Procedure chk_delete
489 (
490 p_entity_group_id in hxc_entity_groups.entity_group_id%TYPE
491 ) IS
492 --
493 l_proc varchar2(72);
494 --
495 --
496 /*
497 CURSOR csr_chk_pref IS
498 SELECT 'exists'
499 FROM sys.dual
500 WHERE EXISTS (
501 SELECT 'x'
502 FROM hxc_resource_all_elig_pref_v
503 WHERE preference_code = 'TS_PER_RETRIEVAL_RULES'
504 AND attribute1 = TO_CHAR(p_entity_group_id) );
505 */
506
507 l_exists VARCHAR2(6) := NULL;
508
509 BEGIN
510 g_debug := hr_utility.debug_enabled;
511
512 if g_debug then
513 l_proc := g_package||'chk_delete';
514 hr_utility.set_location('Entering:'||l_proc, 5);
515 end if;
516
517 -- check that entity_group is not being used in the pref hierarchy
518 -- call function num_hierarchy_occurances to check for data integrity.
519
520 /*OPEN csr_chk_pref;
521 FETCH csr_chk_pref INTO l_exists;
522 CLOSE csr_chk_pref;*/
523
524 if g_debug then
525 hr_utility.set_location('Calling num_hierarchy_occurances:'||l_proc,10);
526 end if;
527 l_exists := HXC_PREFERENCE_EVALUATION.num_hierarchy_occurances
528 ('TS_PER_RETRIEVAL_RULES'
529 ,1
530 ,TO_CHAR(p_entity_group_id));
531 if g_debug then
532 hr_utility.set_location('After calling num_hierarchy_occurances:'||l_proc,20);
533 end if;
534 IF l_exists <> 0 THEN
535 --
536 hr_utility.set_message(809, 'HXC_HEG_RR_IN_USE');
537 hr_utility.raise_error;
538 --
539 END IF;
540 --
541 if g_debug then
542 hr_utility.set_location('Processing: '||l_proc, 60);
543 end if;
544 --
545 END chk_delete;
546 --
547 END hxc_retrieval_rule_grp_api;