1: PACKAGE BODY HXC_LOCK_API AS
2: /* $Header: hxclockapi.pkb 120.4 2005/09/23 05:29:07 nissharm noship $ */
3:
4: g_debug boolean := hr_utility.debug_enabled;
5:
6: -- ----------------------------------------------------------------------------
7: -- |---------------------------< request_lock > ----------------------|
8: -- ----------------------------------------------------------------------------
156:
157:
158: BEGIN
159:
160: g_debug := hr_utility.debug_enabled;
161:
162: -- quick check to denormilize the data and make
163: -- sure the passed data are correct
164:
172: --IF (p_resource_id = 7976) THEN
173: /*
174:
175: if g_debug then
176: hr_utility.trace('JOEL - ----------------------------------');
177: hr_utility.trace('JOEL - request_lock 1 :'||p_resource_id);
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
173: /*
174:
175: if g_debug then
176: hr_utility.trace('JOEL - ----------------------------------');
177: hr_utility.trace('JOEL - request_lock 1 :'||p_resource_id);
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
174:
175: if g_debug then
176: hr_utility.trace('JOEL - ----------------------------------');
177: hr_utility.trace('JOEL - request_lock 1 :'||p_resource_id);
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
175: if g_debug then
176: hr_utility.trace('JOEL - ----------------------------------');
177: hr_utility.trace('JOEL - request_lock 1 :'||p_resource_id);
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
183: hr_utility.trace('JOEL - request_lock 1: '||p_expiration_time);
176: hr_utility.trace('JOEL - ----------------------------------');
177: hr_utility.trace('JOEL - request_lock 1 :'||p_resource_id);
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
183: hr_utility.trace('JOEL - request_lock 1: '||p_expiration_time);
184: hr_utility.trace('JOEL - request_lock 1: '||p_row_lock_id);
177: hr_utility.trace('JOEL - request_lock 1 :'||p_resource_id);
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
183: hr_utility.trace('JOEL - request_lock 1: '||p_expiration_time);
184: hr_utility.trace('JOEL - request_lock 1: '||p_row_lock_id);
185: end if;
178: hr_utility.trace('JOEL - request_lock 1 :'||p_process_locker_type);
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
183: hr_utility.trace('JOEL - request_lock 1: '||p_expiration_time);
184: hr_utility.trace('JOEL - request_lock 1: '||p_row_lock_id);
185: end if;
186:
179: hr_utility.trace('JOEL - request_lock 1: '||p_start_time);
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
183: hr_utility.trace('JOEL - request_lock 1: '||p_expiration_time);
184: hr_utility.trace('JOEL - request_lock 1: '||p_row_lock_id);
185: end if;
186:
187: */
180: hr_utility.trace('JOEL - request_lock 1: '||p_stop_time);
181: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_id);
182: hr_utility.trace('JOEL - request_lock 1: '||p_time_building_block_ovn);
183: hr_utility.trace('JOEL - request_lock 1: '||p_expiration_time);
184: hr_utility.trace('JOEL - request_lock 1: '||p_row_lock_id);
185: end if;
186:
187: */
188:
225: -- start_time and stop_time does not match
226: -- then we are releasing the lock and we are
227: -- requesting a new one)
228: if g_debug then
229: hr_utility.trace('JOEL - request_lock 11: ');
230: end if;
231: release_lock (p_row_lock_id => p_row_lock_id);
232: --
233: p_row_lock_id := null;
256:
257:
258:
259: if g_debug then
260: hr_utility.trace('JOEL - request_lock 4');
261: end if;
262:
263:
264: -- check if there is not a check already.
274: ,p_time_building_block_scope => l_tc_scope
275: ,p_process_locker_type_id => l_locker_type_req_id);
276:
277: if g_debug then
278: hr_utility.trace('JOEL - request_lock 2');
279: end if;
280:
281: --if locked then stop the request_lock process
282: IF l_timecard_locked THEN
283: RETURN;
284: END IF;
285:
286: if g_debug then
287: hr_utility.trace('JOEL - request_lock 2-1');
288: end if;
289:
290:
291:
298: -- we need to insert row in hxc_locks
299: IF l_tbb_id is not null THEN
300:
301: if g_debug then
302: hr_utility.trace('JOEL - request_lock 3 :'||l_tc_scope);
303: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
304: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
305: hr_utility.trace('JOEL - request_lock 3: '||l_resource_id);
306: hr_utility.trace('JOEL - request_lock 3: '||l_expiration_time);
299: IF l_tbb_id is not null THEN
300:
301: if g_debug then
302: hr_utility.trace('JOEL - request_lock 3 :'||l_tc_scope);
303: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
304: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
305: hr_utility.trace('JOEL - request_lock 3: '||l_resource_id);
306: hr_utility.trace('JOEL - request_lock 3: '||l_expiration_time);
307:
300:
301: if g_debug then
302: hr_utility.trace('JOEL - request_lock 3 :'||l_tc_scope);
303: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
304: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
305: hr_utility.trace('JOEL - request_lock 3: '||l_resource_id);
306: hr_utility.trace('JOEL - request_lock 3: '||l_expiration_time);
307:
308: end if;
301: if g_debug then
302: hr_utility.trace('JOEL - request_lock 3 :'||l_tc_scope);
303: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
304: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
305: hr_utility.trace('JOEL - request_lock 3: '||l_resource_id);
306: hr_utility.trace('JOEL - request_lock 3: '||l_expiration_time);
307:
308: end if;
309:
302: hr_utility.trace('JOEL - request_lock 3 :'||l_tc_scope);
303: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
304: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
305: hr_utility.trace('JOEL - request_lock 3: '||l_resource_id);
306: hr_utility.trace('JOEL - request_lock 3: '||l_expiration_time);
307:
308: end if;
309:
310: IF (l_tc_scope is null or l_resource_id is null
318: l_tc_scope = 'TIMECARD_TEMPLATE' or
319: l_tc_scope = 'DETAIL' THEN
320:
321: if g_debug then
322: hr_utility.trace('JOEL - request_lock 3-1: ' || p_time_building_block_id);
323: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
324: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
325: end if;
326:
319: l_tc_scope = 'DETAIL' THEN
320:
321: if g_debug then
322: hr_utility.trace('JOEL - request_lock 3-1: ' || p_time_building_block_id);
323: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
324: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
325: end if;
326:
327: hxc_lock_util.insert_lock
320:
321: if g_debug then
322: hr_utility.trace('JOEL - request_lock 3-1: ' || p_time_building_block_id);
323: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
324: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
325: end if;
326:
327: hxc_lock_util.insert_lock
328: (p_locker_type_id => l_locker_type_req_id
335: ,p_expiration_time => l_expiration_time
336: ,p_row_lock_id => p_row_lock_id
337: );
338: if g_debug then
339: hr_utility.trace('JOEL - request_lock 3-1: ' || p_row_lock_id);
340: end if;
341:
342: p_locked_success := TRUE;
343:
343:
344: ELSIF l_tc_scope = 'APPLICATION_PERIOD' THEN
345:
346: if g_debug then
347: hr_utility.trace('JOEL - request_lock 4: ' || p_time_building_block_id);
348: end if;
349: -- we need to lock all the details for this application period
350: FOR crs_app_period_detail in c_app_period_detail(l_tbb_id)
351: LOOP
349: -- we need to lock all the details for this application period
350: FOR crs_app_period_detail in c_app_period_detail(l_tbb_id)
351: LOOP
352: if g_debug then
353: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
354: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
355: hr_utility.trace('JOEL - p_time_building_block_id 3: '||p_time_building_block_id);
356: end if;
357:
350: FOR crs_app_period_detail in c_app_period_detail(l_tbb_id)
351: LOOP
352: if g_debug then
353: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
354: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
355: hr_utility.trace('JOEL - p_time_building_block_id 3: '||p_time_building_block_id);
356: end if;
357:
358: -- if we arrive here that means we did not find a detail
351: LOOP
352: if g_debug then
353: hr_utility.trace('JOEL - request_lock 3: '||l_start_time);
354: hr_utility.trace('JOEL - request_lock 3: '||l_stop_time);
355: hr_utility.trace('JOEL - p_time_building_block_id 3: '||p_time_building_block_id);
356: end if;
357:
358: -- if we arrive here that means we did not find a detail
359: -- locked and then we can insert a new lock
390:
391: ELSE
392:
393: if g_debug then
394: hr_utility.trace('JOEL - request_lock 5');
395: end if;
396:
397: -- we need to lock a period
398: hxc_lock_util.insert_lock
411:
412: END IF;
413:
414: if g_debug then
415: hr_utility.trace('messages :');
416: end if;
417:
418:
419: --l_dummy := p_messages.first;
421: --EXIT WHEN
422: -- (NOT p_messages.exists(l_dummy));
423:
424: --if g_debug then
425: -- hr_utility.trace('message_name :'||p_messages(l_dummy).message_name);
426: -- hr_utility.trace('message_level :'||p_messages(l_dummy).message_level);
427: --end if;
428:
429: --l_dummy := p_messages.next(l_dummy);
422: -- (NOT p_messages.exists(l_dummy));
423:
424: --if g_debug then
425: -- hr_utility.trace('message_name :'||p_messages(l_dummy).message_name);
426: -- hr_utility.trace('message_level :'||p_messages(l_dummy).message_level);
427: --end if;
428:
429: --l_dummy := p_messages.next(l_dummy);
430:
534: l_grant VARCHAR2(1);
535:
536: BEGIN
537:
538: g_debug := hr_utility.debug_enabled;
539:
540: p_timecard_locked := FALSE;
541:
542: --l_resource_id := p_resource_id;
572:
573: --dbms_output.put_line('JOEL - check_lock 3');
574:
575: if g_debug then
576: hr_utility.trace('JOEL - check_lock 3');
577: end if;
578:
579: IF p_time_building_block_id is not null THEN
580: -- following the scope we need to do different thing.
716: FOR crs_app_period_detail in c_app_period_detail(p_time_building_block_id)
717: LOOP
718:
719: if g_debug then
720: hr_utility.trace('JOEL - check_lock 10 :');
721: end if;
722:
723: -- try to find the lock
724: hxc_lock_util.check_row_lock
734: -- check if we can stop the process
735: IF p_timecard_locked THEN
736: RETURN;
737: if g_debug then
738: hr_utility.trace('JOEL - check_lock 11 :');
739: end if;
740: END IF;
741:
742: -- for each detail we need to check if the parent is locked
748: CLOSE c_detail_timecard;
749:
750: --dbms_output.put_line('JOEL - check_lock 11 :');
751: if g_debug then
752: hr_utility.trace('JOEL - check_lock 12 :');
753: end if;
754:
755: -- try to find the lock
756: hxc_lock_util.check_row_lock
764:
765: -- check if we can stop the process
766: IF p_timecard_locked THEN
767: if g_debug then
768: hr_utility.trace('JOEL - check_lock 13 :');
769: end if;
770: RETURN;
771: END IF;
772:
777: -- we are in the case of a checking a lock for a period for a resource
778: FOR crs_resource_period_lock in c_resource_period_lock(p_resource_id) LOOP
779:
780: if g_debug then
781: hr_utility.trace('JOEL - check_lock 12 :');
782: end if;
783:
784: hxc_lock_util.check_date_lock
785: (p_locker_type_requestor_id => p_process_locker_type_id
828:
829: IF p_row_lock_id is not null THEN
830: /*
831:
832: g_debug := hr_utility.debug_enabled;
833:
834: if g_debug then
835: hr_utility.trace('J a'||trim(p_row_lock_id)||'b');
836: end if;
831:
832: g_debug := hr_utility.debug_enabled;
833:
834: if g_debug then
835: hr_utility.trace('J a'||trim(p_row_lock_id)||'b');
836: end if;
837:
838: */
839: OPEN c_lock;
1047: l_parent_tbb_ovn NUMBER;
1048:
1049: BEGIN
1050:
1051: g_debug := hr_utility.debug_enabled;
1052:
1053: p_released_success := FALSE;
1054:
1055:
1053: p_released_success := FALSE;
1054:
1055:
1056: if g_debug then
1057: hr_utility.trace('--------------------------------------------');
1058: hr_utility.trace('JOEL - delete_lock 10 '||p_process_locker_type);
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1054:
1055:
1056: if g_debug then
1057: hr_utility.trace('--------------------------------------------');
1058: hr_utility.trace('JOEL - delete_lock 10 '||p_process_locker_type);
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1055:
1056: if g_debug then
1057: hr_utility.trace('--------------------------------------------');
1058: hr_utility.trace('JOEL - delete_lock 10 '||p_process_locker_type);
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1056: if g_debug then
1057: hr_utility.trace('--------------------------------------------');
1058: hr_utility.trace('JOEL - delete_lock 10 '||p_process_locker_type);
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1064: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_ovn);
1057: hr_utility.trace('--------------------------------------------');
1058: hr_utility.trace('JOEL - delete_lock 10 '||p_process_locker_type);
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1064: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_ovn);
1065: hr_utility.trace('JOEL - delete_lock 10: '||p_row_lock_id);
1058: hr_utility.trace('JOEL - delete_lock 10 '||p_process_locker_type);
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1064: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_ovn);
1065: hr_utility.trace('JOEL - delete_lock 10: '||p_row_lock_id);
1066:
1059: hr_utility.trace('JOEL - delete_lock 10 :'||p_resource_id);
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1064: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_ovn);
1065: hr_utility.trace('JOEL - delete_lock 10: '||p_row_lock_id);
1066:
1067: end if;
1060: hr_utility.trace('JOEL - delete_lock 10 :'||p_process_locker_type);
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1064: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_ovn);
1065: hr_utility.trace('JOEL - delete_lock 10: '||p_row_lock_id);
1066:
1067: end if;
1068:
1061: hr_utility.trace('JOEL - delete_lock 10: '||p_start_time);
1062: hr_utility.trace('JOEL - delete_lock 10: '||p_stop_time);
1063: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_id);
1064: hr_utility.trace('JOEL - delete_lock 10: '||p_time_building_block_ovn);
1065: hr_utility.trace('JOEL - delete_lock 10: '||p_row_lock_id);
1066:
1067: end if;
1068:
1069: -- if it is not locked then now
1070: -- we need to insert row in hxc_locks
1071:
1072: IF p_row_lock_id is not null THEN
1073: if g_debug then
1074: hr_utility.trace('JOEL - delete_lock 10 ');
1075: end if;
1076: hxc_lock_util.delete_lock
1077: (p_rowid => p_row_lock_id
1078: ,p_locker_type_id => null