31:
32: --
33: PROCEDURE controller_init(p_migration_id IN NUMBER,
34: r_migration_data IN OUT
35: hr_dm_utility.r_migration_rec,
36: p_request_data IN VARCHAR2) IS
37: --
38:
39: l_current_phase_status VARCHAR2(30);
77: --
78: BEGIN
79: --
80:
81: hr_dm_utility.message('ROUT','entry:hr_dm_master.controller_init', 5);
82: hr_dm_utility.message('PARA','(p_migration_id - ' || p_migration_id ||
83: ')(r_migration_data - record' ||
84: ')(p_request_data - ' || p_request_data || ')', 10);
85:
78: BEGIN
79: --
80:
81: hr_dm_utility.message('ROUT','entry:hr_dm_master.controller_init', 5);
82: hr_dm_utility.message('PARA','(p_migration_id - ' || p_migration_id ||
83: ')(r_migration_data - record' ||
84: ')(p_request_data - ' || p_request_data || ')', 10);
85:
86:
162: l_valid_migration := hr_dm_business.validate_migration(r_migration_data);
163: IF (l_valid_migration = 'E') THEN
164: -- raise error
165: l_fatal_error_message := 'Invalid migration - business rule broken';
166: hr_dm_utility.update_migrations(p_new_status => 'E',
167: p_id => p_migration_id);
168: RAISE e_fatal_error;
169: END IF;
170: END IF;
170: END IF;
171:
172: -- update status of migration to started (un-paused)
173: IF (NVL(p_request_data, '?') = '?') THEN
174: hr_dm_utility.update_migrations(p_new_status => 'S',
175: p_id => p_migration_id);
176: END IF;
177:
178:
175: p_id => p_migration_id);
176: END IF;
177:
178:
179: hr_dm_utility.message('INFO','Main controller initialized', 15);
180: hr_dm_utility.message('SUMM','Main controller initialized', 20);
181: hr_dm_utility.message('ROUT','exit:hr_dm_master.controller_init', 25);
182: hr_dm_utility.message('PARA','(none)', 30);
183:
176: END IF;
177:
178:
179: hr_dm_utility.message('INFO','Main controller initialized', 15);
180: hr_dm_utility.message('SUMM','Main controller initialized', 20);
181: hr_dm_utility.message('ROUT','exit:hr_dm_master.controller_init', 25);
182: hr_dm_utility.message('PARA','(none)', 30);
183:
184:
177:
178:
179: hr_dm_utility.message('INFO','Main controller initialized', 15);
180: hr_dm_utility.message('SUMM','Main controller initialized', 20);
181: hr_dm_utility.message('ROUT','exit:hr_dm_master.controller_init', 25);
182: hr_dm_utility.message('PARA','(none)', 30);
183:
184:
185:
178:
179: hr_dm_utility.message('INFO','Main controller initialized', 15);
180: hr_dm_utility.message('SUMM','Main controller initialized', 20);
181: hr_dm_utility.message('ROUT','exit:hr_dm_master.controller_init', 25);
182: hr_dm_utility.message('PARA','(none)', 30);
183:
184:
185:
186: -- error handling
185:
186: -- error handling
187: EXCEPTION
188: WHEN e_fatal_error THEN
189: hr_dm_utility.error(SQLCODE,'hr_dm_range.main_controller',
190: l_fatal_error_message,'R');
191: report_error(l_phase_name, p_migration_id,
192: l_fatal_error_message ||
193: ' in hr_dm_master.main_controller', 'M');
192: l_fatal_error_message ||
193: ' in hr_dm_master.main_controller', 'M');
194: RAISE;
195: WHEN OTHERS THEN
196: hr_dm_utility.error(SQLCODE,'hr_dm_master.main_controller',
197: '(none)','R');
198: report_error(l_phase_name, p_migration_id,
199: 'Untrapped error in hr_dm_master.main_controller', 'M');
200: RAISE;
240: --
241: BEGIN
242: --
243:
244: hr_dm_utility.message('ROUT','entry:hr_dm_master.insert_request', 5);
245: hr_dm_utility.message('PARA','(p_phase - ' || p_phase ||
246: ')(p_request_id - ' || p_request_id ||
247: ')(p_master_slave - ' || p_master_slave ||
248: ')(p_migration_id - ' || p_migration_id ||
241: BEGIN
242: --
243:
244: hr_dm_utility.message('ROUT','entry:hr_dm_master.insert_request', 5);
245: hr_dm_utility.message('PARA','(p_phase - ' || p_phase ||
246: ')(p_request_id - ' || p_request_id ||
247: ')(p_master_slave - ' || p_master_slave ||
248: ')(p_migration_id - ' || p_migration_id ||
249: ')(p_phase_id - ' || p_phase_id ||
280: WHERE request_id = p_request_id);
281:
282: COMMIT;
283:
284: hr_dm_utility.message('INFO','Inserted into hr_dm_migration_requests', 15);
285: hr_dm_utility.message('SUMM','Inserted into hr_dm_migration_requests', 20);
286: hr_dm_utility.message('ROUT','exit:hr_dm_master.insert_request', 25);
287: hr_dm_utility.message('PARA','(none)', 30);
288:
281:
282: COMMIT;
283:
284: hr_dm_utility.message('INFO','Inserted into hr_dm_migration_requests', 15);
285: hr_dm_utility.message('SUMM','Inserted into hr_dm_migration_requests', 20);
286: hr_dm_utility.message('ROUT','exit:hr_dm_master.insert_request', 25);
287: hr_dm_utility.message('PARA','(none)', 30);
288:
289: -- error handling
282: COMMIT;
283:
284: hr_dm_utility.message('INFO','Inserted into hr_dm_migration_requests', 15);
285: hr_dm_utility.message('SUMM','Inserted into hr_dm_migration_requests', 20);
286: hr_dm_utility.message('ROUT','exit:hr_dm_master.insert_request', 25);
287: hr_dm_utility.message('PARA','(none)', 30);
288:
289: -- error handling
290: EXCEPTION
283:
284: hr_dm_utility.message('INFO','Inserted into hr_dm_migration_requests', 15);
285: hr_dm_utility.message('SUMM','Inserted into hr_dm_migration_requests', 20);
286: hr_dm_utility.message('ROUT','exit:hr_dm_master.insert_request', 25);
287: hr_dm_utility.message('PARA','(none)', 30);
288:
289: -- error handling
290: EXCEPTION
291: WHEN OTHERS THEN
288:
289: -- error handling
290: EXCEPTION
291: WHEN OTHERS THEN
292: hr_dm_utility.error(SQLCODE,'hr_dm_master.insert_request','(none)','R');
293: RAISE;
294:
295:
296: --
316: -- ------------------------------------------------------------------------
317:
318: --
319: PROCEDURE spawn_slaves(p_current_phase IN VARCHAR2,
320: r_migration_data IN hr_dm_utility.r_migration_rec) IS
321: --
322:
323: l_counter NUMBER;
324: l_request_id NUMBER;
332: --
333: BEGIN
334: --
335:
336: hr_dm_utility.message('ROUT','entry:hr_dm_master.spawn_slaves', 5);
337: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
338: ')(r_migration_data - record)', 10);
339:
340:
333: BEGIN
334: --
335:
336: hr_dm_utility.message('ROUT','entry:hr_dm_master.spawn_slaves', 5);
337: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
338: ')(r_migration_data - record)', 10);
339:
340:
341: -- set up name for appropriate concurrent slave
341: -- set up name for appropriate concurrent slave
342: l_slave_program := 'HRDMSLV' || p_current_phase;
343:
344: -- get the current phase_id
345: l_phase_id := hr_dm_utility.get_phase_id(p_current_phase,
346: r_migration_data.migration_id);
347:
348: -- find the number of threads to use
349: l_threads := hr_dm_utility.number_of_threads(
345: l_phase_id := hr_dm_utility.get_phase_id(p_current_phase,
346: r_migration_data.migration_id);
347:
348: -- find the number of threads to use
349: l_threads := hr_dm_utility.number_of_threads(
350: r_migration_data.business_group_id);
351: -- only single thread for UP phase
352: IF (p_current_phase = 'UP') THEN
353: l_threads := 1;
363: l_threads := 1;
364: END IF;
365:
366: -- set current processing
367: hr_dm_utility.set_process(l_threads || ' slaves',
368: p_current_phase,
369: r_migration_data.migration_id);
370:
371:
369: r_migration_data.migration_id);
370:
371:
372: FOR l_counter IN 1..l_threads LOOP
373: hr_dm_utility.message('INFO','Spawning slave #' || l_counter, 16);
374:
375:
376: l_request_id := fnd_request.submit_request(
377: application => 'PER',
391: p_migration_id => r_migration_data.migration_id,
392: p_phase_id => l_phase_id);
393:
394: COMMIT;
395: hr_dm_utility.message('INFO','Slave request ID#' || l_request_id, 17);
396: IF (l_request_id = 0) THEN
397: l_fatal_error_message := 'Unable to start slave process';
398: report_error(p_current_phase, r_migration_data.migration_id,
399: l_fatal_error_message, 'P');
400: RAISE e_fatal_error;
401: END IF;
402: END LOOP;
403:
404: hr_dm_utility.message('INFO','Spawned slaves', 15);
405: hr_dm_utility.message('SUMM','Spawned slaves', 20);
406: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
407: hr_dm_utility.message('PARA','(none)', 30);
408:
401: END IF;
402: END LOOP;
403:
404: hr_dm_utility.message('INFO','Spawned slaves', 15);
405: hr_dm_utility.message('SUMM','Spawned slaves', 20);
406: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
407: hr_dm_utility.message('PARA','(none)', 30);
408:
409:
402: END LOOP;
403:
404: hr_dm_utility.message('INFO','Spawned slaves', 15);
405: hr_dm_utility.message('SUMM','Spawned slaves', 20);
406: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
407: hr_dm_utility.message('PARA','(none)', 30);
408:
409:
410:
403:
404: hr_dm_utility.message('INFO','Spawned slaves', 15);
405: hr_dm_utility.message('SUMM','Spawned slaves', 20);
406: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
407: hr_dm_utility.message('PARA','(none)', 30);
408:
409:
410:
411: -- error handling
410:
411: -- error handling
412: EXCEPTION
413: WHEN e_fatal_error THEN
414: hr_dm_utility.error(SQLCODE,'hr_dm_master.spawn_slaves',
415: l_fatal_error_message,'R');
416: report_error(p_current_phase, r_migration_data.migration_id,
417: 'Error in hr_dm_master.spawn_slaves', 'P');
418: RAISE;
416: report_error(p_current_phase, r_migration_data.migration_id,
417: 'Error in hr_dm_master.spawn_slaves', 'P');
418: RAISE;
419: WHEN OTHERS THEN
420: hr_dm_utility.error(SQLCODE,'hr_dm_master.spawn_slaves','(none)','R');
421: report_error(p_current_phase, r_migration_data.migration_id,
422: 'Untrapped error in hr_dm_master.spawn_slaves', 'P');
423: RAISE;
424:
446: -- ------------------------------------------------------------------------
447:
448: --
449: FUNCTION slave_status(p_current_phase IN VARCHAR2,
450: r_migration_data IN hr_dm_utility.r_migration_rec)
451: RETURN VARCHAR2 IS
452: --
453:
454: l_slave_status VARCHAR2(1);
473: --
474: BEGIN
475: --
476:
477: hr_dm_utility.message('ROUT','entry:hr_dm_master.slave_status', 5);
478: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
479: ')(r_migration_data - record)', 10);
480:
481: -- get the current phase_id
474: BEGIN
475: --
476:
477: hr_dm_utility.message('ROUT','entry:hr_dm_master.slave_status', 5);
478: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
479: ')(r_migration_data - record)', 10);
480:
481: -- get the current phase_id
482: l_phase_id := hr_dm_utility.get_phase_id(p_current_phase,
478: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
479: ')(r_migration_data - record)', 10);
480:
481: -- get the current phase_id
482: l_phase_id := hr_dm_utility.get_phase_id(p_current_phase,
483: r_migration_data.migration_id);
484:
485: -- check if a slave has errored
486: OPEN csr_requests;
499: END LOOP;
500: CLOSE csr_requests;
501:
502:
503: hr_dm_utility.message('INFO','Slave status request', 15);
504: hr_dm_utility.message('SUMM','Slave status request', 20);
505: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
506: hr_dm_utility.message('PARA','(l_slave_error - ' || l_slave_error ||
507: ')', 30);
500: CLOSE csr_requests;
501:
502:
503: hr_dm_utility.message('INFO','Slave status request', 15);
504: hr_dm_utility.message('SUMM','Slave status request', 20);
505: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
506: hr_dm_utility.message('PARA','(l_slave_error - ' || l_slave_error ||
507: ')', 30);
508:
501:
502:
503: hr_dm_utility.message('INFO','Slave status request', 15);
504: hr_dm_utility.message('SUMM','Slave status request', 20);
505: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
506: hr_dm_utility.message('PARA','(l_slave_error - ' || l_slave_error ||
507: ')', 30);
508:
509:
502:
503: hr_dm_utility.message('INFO','Slave status request', 15);
504: hr_dm_utility.message('SUMM','Slave status request', 20);
505: hr_dm_utility.message('ROUT','exit:hr_dm_master.spawn_slaves', 25);
506: hr_dm_utility.message('PARA','(l_slave_error - ' || l_slave_error ||
507: ')', 30);
508:
509:
510: RETURN(l_slave_error);
511:
512: -- error handling
513: EXCEPTION
514: WHEN OTHERS THEN
515: hr_dm_utility.error(SQLCODE,'hr_dm_master.slave_status','(none)','R');
516: report_error(p_current_phase, r_migration_data.migration_id,
517: 'Untrapped error in hr_dm_master.slave_status', 'P');
518: RAISE;
519:
554: --
555: BEGIN
556: --
557:
558: hr_dm_utility.message('ROUT','entry:hr_dm_master.report_error', 5);
559: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
560: ')(p_migration - ' || p_migration ||
561: ')(p_error_message - ' || p_error_message ||
562: ')(p_stage - ' || p_stage || ')', 10);
555: BEGIN
556: --
557:
558: hr_dm_utility.message('ROUT','entry:hr_dm_master.report_error', 5);
559: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
560: ')(p_migration - ' || p_migration ||
561: ')(p_error_message - ' || p_error_message ||
562: ')(p_stage - ' || p_stage || ')', 10);
563:
564:
565: -- update status to show error (E)
566: -- update approriate phase, migration, etc.
567: IF (p_stage = 'P') THEN
568: hr_dm_utility.update_phases(p_new_status => 'E',
569: p_id => hr_dm_utility.get_phase_id(
570: p_current_phase, p_migration));
571: END IF;
572:
565: -- update status to show error (E)
566: -- update approriate phase, migration, etc.
567: IF (p_stage = 'P') THEN
568: hr_dm_utility.update_phases(p_new_status => 'E',
569: p_id => hr_dm_utility.get_phase_id(
570: p_current_phase, p_migration));
571: END IF;
572:
573: IF (p_stage = 'M') THEN
570: p_current_phase, p_migration));
571: END IF;
572:
573: IF (p_stage = 'M') THEN
574: hr_dm_utility.update_migrations(p_new_status => 'E', p_id => p_migration);
575: END IF;
576:
577:
578: hr_dm_utility.message('INFO','Error reported', 15);
574: hr_dm_utility.update_migrations(p_new_status => 'E', p_id => p_migration);
575: END IF;
576:
577:
578: hr_dm_utility.message('INFO','Error reported', 15);
579: hr_dm_utility.message('SUMM','Error reported', 20);
580: hr_dm_utility.message('ROUT','exit:hr_dm_master.report_error', 25);
581: hr_dm_utility.message('PARA','(none)', 30);
582:
575: END IF;
576:
577:
578: hr_dm_utility.message('INFO','Error reported', 15);
579: hr_dm_utility.message('SUMM','Error reported', 20);
580: hr_dm_utility.message('ROUT','exit:hr_dm_master.report_error', 25);
581: hr_dm_utility.message('PARA','(none)', 30);
582:
583:
576:
577:
578: hr_dm_utility.message('INFO','Error reported', 15);
579: hr_dm_utility.message('SUMM','Error reported', 20);
580: hr_dm_utility.message('ROUT','exit:hr_dm_master.report_error', 25);
581: hr_dm_utility.message('PARA','(none)', 30);
582:
583:
584: --
577:
578: hr_dm_utility.message('INFO','Error reported', 15);
579: hr_dm_utility.message('SUMM','Error reported', 20);
580: hr_dm_utility.message('ROUT','exit:hr_dm_master.report_error', 25);
581: hr_dm_utility.message('PARA','(none)', 30);
582:
583:
584: --
585: END report_error;
607: -- ------------------------------------------------------------------------
608:
609: --
610: FUNCTION work_required(p_current_phase IN VARCHAR2,
611: r_migration_data IN hr_dm_utility.r_migration_rec)
612: RETURN VARCHAR2 IS
613: --
614:
615: l_work VARCHAR2(1);
643: --
644: BEGIN
645: --
646:
647: hr_dm_utility.message('ROUT','entry:hr_dm_master.work_required', 5);
648: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
649: ')(r_migration_data - record)', 10);
650:
651: -- get the current phase_id
644: BEGIN
645: --
646:
647: hr_dm_utility.message('ROUT','entry:hr_dm_master.work_required', 5);
648: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
649: ')(r_migration_data - record)', 10);
650:
651: -- get the current phase_id
652: l_phase_id := hr_dm_utility.get_phase_id(p_current_phase,
648: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
649: ')(r_migration_data - record)', 10);
650:
651: -- get the current phase_id
652: l_phase_id := hr_dm_utility.get_phase_id(p_current_phase,
653: r_migration_data.migration_id);
654:
655: l_work := 'Y';
656:
658: IF (p_current_phase IN ('G', 'R', 'DA', 'UA', 'UP', 'C')) THEN
659: OPEN csr_phase_items;
660: FETCH csr_phase_items INTO l_required;
661: IF (csr_phase_items%NOTFOUND) THEN
662: hr_dm_utility.message('INFO','No work required for phase ' ||
663: p_current_phase, 11);
664: l_work := 'N';
665: hr_dm_utility.update_phases(p_new_status => 'C',
666: p_id => l_phase_id);
661: IF (csr_phase_items%NOTFOUND) THEN
662: hr_dm_utility.message('INFO','No work required for phase ' ||
663: p_current_phase, 11);
664: l_work := 'N';
665: hr_dm_utility.update_phases(p_new_status => 'C',
666: p_id => l_phase_id);
667: END IF;
668: CLOSE csr_phase_items;
669: END IF;
671:
672: -- check phase items for DP or D phases to see if any migration ranges
673: -- to process
674: IF (p_current_phase IN ('DP', 'D')) THEN
675: hr_dm_utility.message('INFO','checking DP/D - ' || p_current_phase, 5);
676: -- get the range phase_id
677: l_range_phase_id := hr_dm_utility.get_phase_id('R',
678: r_migration_data.migration_id);
679: hr_dm_utility.message('INFO','l_range_phase_id - ' || l_range_phase_id, 5);
673: -- to process
674: IF (p_current_phase IN ('DP', 'D')) THEN
675: hr_dm_utility.message('INFO','checking DP/D - ' || p_current_phase, 5);
676: -- get the range phase_id
677: l_range_phase_id := hr_dm_utility.get_phase_id('R',
678: r_migration_data.migration_id);
679: hr_dm_utility.message('INFO','l_range_phase_id - ' || l_range_phase_id, 5);
680: -- find phase_item_id for D/DP phase
681: OPEN csr_ddp_pi;
675: hr_dm_utility.message('INFO','checking DP/D - ' || p_current_phase, 5);
676: -- get the range phase_id
677: l_range_phase_id := hr_dm_utility.get_phase_id('R',
678: r_migration_data.migration_id);
679: hr_dm_utility.message('INFO','l_range_phase_id - ' || l_range_phase_id, 5);
680: -- find phase_item_id for D/DP phase
681: OPEN csr_ddp_pi;
682: LOOP
683: FETCH csr_ddp_pi INTO l_phase_item_id, l_group_id;
680: -- find phase_item_id for D/DP phase
681: OPEN csr_ddp_pi;
682: LOOP
683: FETCH csr_ddp_pi INTO l_phase_item_id, l_group_id;
684: hr_dm_utility.message('INFO','l_phase_item_id - ' || l_phase_item_id, 5);
685: hr_dm_utility.message('INFO','l_group_id - ' || l_group_id, 5);
686: EXIT WHEN csr_ddp_pi%NOTFOUND;
687:
688: -- see if any migration ranges to process for this phase_item_id
681: OPEN csr_ddp_pi;
682: LOOP
683: FETCH csr_ddp_pi INTO l_phase_item_id, l_group_id;
684: hr_dm_utility.message('INFO','l_phase_item_id - ' || l_phase_item_id, 5);
685: hr_dm_utility.message('INFO','l_group_id - ' || l_group_id, 5);
686: EXIT WHEN csr_ddp_pi%NOTFOUND;
687:
688: -- see if any migration ranges to process for this phase_item_id
689: OPEN csr_mig_ranges;
687:
688: -- see if any migration ranges to process for this phase_item_id
689: OPEN csr_mig_ranges;
690: FETCH csr_mig_ranges INTO l_required;
691: hr_dm_utility.message('INFO','l_required - ' || l_required, 5);
692: IF (csr_mig_ranges%NOTFOUND) THEN
693: -- mark phase item as started and then complete to ensure that
694: -- the start and end times are set
695: hr_dm_utility.message('INFO','No work required for group ' ||
691: hr_dm_utility.message('INFO','l_required - ' || l_required, 5);
692: IF (csr_mig_ranges%NOTFOUND) THEN
693: -- mark phase item as started and then complete to ensure that
694: -- the start and end times are set
695: hr_dm_utility.message('INFO','No work required for group ' ||
696: l_group_id, 12);
697:
698: hr_dm_utility.update_phase_items(p_new_status => 'S',
699: p_id => l_phase_item_id);
694: -- the start and end times are set
695: hr_dm_utility.message('INFO','No work required for group ' ||
696: l_group_id, 12);
697:
698: hr_dm_utility.update_phase_items(p_new_status => 'S',
699: p_id => l_phase_item_id);
700: hr_dm_utility.update_phase_items(p_new_status => 'C',
701: p_id => l_phase_item_id);
702: END IF;
696: l_group_id, 12);
697:
698: hr_dm_utility.update_phase_items(p_new_status => 'S',
699: p_id => l_phase_item_id);
700: hr_dm_utility.update_phase_items(p_new_status => 'C',
701: p_id => l_phase_item_id);
702: END IF;
703: CLOSE csr_mig_ranges;
704:
707:
708: -- see if any phase items to process
709: -- ie if csr_ddp_pi does not find any phase items
710: IF (l_phase_item_id IS NULL) THEN
711: hr_dm_utility.message('INFO','No work required for phase ' ||
712: p_current_phase, 13);
713: l_work := 'N';
714: hr_dm_utility.update_phases(p_new_status => 'C',
715: p_id => l_phase_id);
710: IF (l_phase_item_id IS NULL) THEN
711: hr_dm_utility.message('INFO','No work required for phase ' ||
712: p_current_phase, 13);
713: l_work := 'N';
714: hr_dm_utility.update_phases(p_new_status => 'C',
715: p_id => l_phase_id);
716: END IF;
717:
718: -- see if phase is complete
715: p_id => l_phase_id);
716: END IF;
717:
718: -- see if phase is complete
719: IF (hr_dm_utility.get_phase_status(p_current_phase,
720: r_migration_data.migration_id) = 'C') THEN
721: l_work := 'N';
722: END IF;
723:
723:
724: END IF;
725:
726:
727: hr_dm_utility.message('INFO','Check work required for phase', 15);
728: hr_dm_utility.message('SUMM','Check work required for phase', 20);
729: hr_dm_utility.message('ROUT','exit:hr_dm_master.work_required', 25);
730: hr_dm_utility.message('PARA','(l_work - ' || l_work || ')', 30);
731:
724: END IF;
725:
726:
727: hr_dm_utility.message('INFO','Check work required for phase', 15);
728: hr_dm_utility.message('SUMM','Check work required for phase', 20);
729: hr_dm_utility.message('ROUT','exit:hr_dm_master.work_required', 25);
730: hr_dm_utility.message('PARA','(l_work - ' || l_work || ')', 30);
731:
732: RETURN(l_work);
725:
726:
727: hr_dm_utility.message('INFO','Check work required for phase', 15);
728: hr_dm_utility.message('SUMM','Check work required for phase', 20);
729: hr_dm_utility.message('ROUT','exit:hr_dm_master.work_required', 25);
730: hr_dm_utility.message('PARA','(l_work - ' || l_work || ')', 30);
731:
732: RETURN(l_work);
733:
726:
727: hr_dm_utility.message('INFO','Check work required for phase', 15);
728: hr_dm_utility.message('SUMM','Check work required for phase', 20);
729: hr_dm_utility.message('ROUT','exit:hr_dm_master.work_required', 25);
730: hr_dm_utility.message('PARA','(l_work - ' || l_work || ')', 30);
731:
732: RETURN(l_work);
733:
734: -- error handling
733:
734: -- error handling
735: EXCEPTION
736: WHEN OTHERS THEN
737: hr_dm_utility.error(SQLCODE,'hr_dm_master.work_required','(none)','R');
738: report_error(p_current_phase, r_migration_data.migration_id,
739: 'Untrapped error in hr_dm_master.work_required', 'P');
740: RAISE;
741:
798:
799: --
800: PROCEDURE master(p_current_phase IN VARCHAR2,
801: p_previous_phase IN VARCHAR2,
802: r_migration_data IN hr_dm_utility.r_migration_rec) IS
803: --
804:
805: l_current_phase_status VARCHAR2(30);
806: e_fatal_error EXCEPTION;
812: --
813: BEGIN
814: --
815:
816: hr_dm_utility.message('ROUT','entry:hr_dm_master.master', 5);
817: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
818: ')(p_previous_phase - ' || p_previous_phase ||
819: ')(r_migration_data - record)', 10);
820:
813: BEGIN
814: --
815:
816: hr_dm_utility.message('ROUT','entry:hr_dm_master.master', 5);
817: hr_dm_utility.message('PARA','(p_current_phase - ' || p_current_phase ||
818: ')(p_previous_phase - ' || p_previous_phase ||
819: ')(r_migration_data - record)', 10);
820:
821: -- see if this is the first run? (l_request_data = NULL or '?')
823: -- is it a restart after slaves have finished? (l_request_data =
824: -- paused phase code)
825: l_request_data := fnd_conc_global.request_data;
826:
827: hr_dm_utility.message('INFO','l_request_data ' || l_request_data, 11);
828: IF (NVL(l_request_data, '?') = '?') THEN
829: -- first run processing...
830:
831: hr_dm_utility.message('INFO','First run processing (pre-pause)', 12);
827: hr_dm_utility.message('INFO','l_request_data ' || l_request_data, 11);
828: IF (NVL(l_request_data, '?') = '?') THEN
829: -- first run processing...
830:
831: hr_dm_utility.message('INFO','First run processing (pre-pause)', 12);
832:
833: -- get status of previous phase, is previous phase completed?
834: -- for the first phase there is no previous phase, so check for
835: -- a NULL previous to bypass this check
832:
833: -- get status of previous phase, is previous phase completed?
834: -- for the first phase there is no previous phase, so check for
835: -- a NULL previous to bypass this check
836: IF ((hr_dm_utility.get_phase_status(p_previous_phase,
837: r_migration_data.migration_id) <> 'C')
838: AND (p_previous_phase IS NOT NULL) ) THEN
839: l_fatal_error_message := 'Previous phase has not completed';
840: report_error(p_current_phase, r_migration_data.migration_id,
842: RAISE e_fatal_error;
843: END IF;
844:
845: -- get status of current phase
846: l_current_phase_status := hr_dm_utility.get_phase_status(p_current_phase,
847: r_migration_data.migration_id);
848:
849: -- is phase complete?
850: IF (l_current_phase_status <> 'C') THEN
851: -- do we need to explicitly rollback using rollback utility?
852: IF ( (l_current_phase_status IN('S', 'E')) AND
853: (p_current_phase IN('I', 'G', 'R', 'DP', 'DA', 'UA',
854: 'UP', 'C', 'D')) ) THEN
855: hr_dm_utility.rollback(p_phase => p_current_phase,
856: p_masterslave => 'MASTER',
857: p_migration_id =>
858: r_migration_data.migration_id);
859: END IF;
858: r_migration_data.migration_id);
859: END IF;
860:
861: -- update status to started
862: hr_dm_utility.update_phases(p_new_status => 'S',
863: p_id => hr_dm_utility.get_phase_id(
864: p_current_phase,
865: r_migration_data.migration_id));
866: COMMIT;
859: END IF;
860:
861: -- update status to started
862: hr_dm_utility.update_phases(p_new_status => 'S',
863: p_id => hr_dm_utility.get_phase_id(
864: p_current_phase,
865: r_migration_data.migration_id));
866: COMMIT;
867:
870:
871: -- generate phase
872: -- create dummy hr_dmv views to avoid compilation errors
873: IF (p_current_phase = 'G') THEN
874: hr_dm_utility.set_process('Pre-processing',
875: p_current_phase,
876: r_migration_data.migration_id);
877: hr_dm_library.create_stub_views(r_migration_data.migration_id);
878: END IF;
881:
882: -- delete phase
883: -- set current processing
884: IF (p_current_phase = 'D') THEN
885: hr_dm_utility.set_process('Pre-processing',
886: p_current_phase,
887: r_migration_data.migration_id);
888: hr_dm_delete.set_active(r_migration_data.migration_id);
889: hr_dm_delete.pre_delete_process(r_migration_data);
907: END IF;
908:
909: ELSE
910: -- processing after being woken up
911: hr_dm_utility.message('INFO','Unpaused processing', 13);
912: -- set request data to indicate un-paused phase
913: fnd_conc_global.set_req_globals(request_data => '?');
914:
915:
916: -- first force check for all required work
917: l_dummy := work_required(p_current_phase, r_migration_data);
918:
919: -- get status of current phase
920: l_current_phase_status := hr_dm_utility.get_phase_status(p_current_phase,
921: r_migration_data.migration_id);
922:
923: -- is it completed?
924: IF (l_current_phase_status <> 'C') THEN
930:
931: -- has any slave errored?
932: -- if so, add warning message to log
933: IF (slave_status(p_current_phase, r_migration_data) = 'Y') THEN
934: hr_dm_utility.message('INFO', 'Warning - ' || p_current_phase ||
935: ' phase slave process errored', 13);
936: END IF;
937:
938: -- call phase specific post processing code
937:
938: -- call phase specific post processing code
939: IF (p_current_phase = 'G') THEN
940: -- set current processing
941: hr_dm_utility.set_process('Post-processing',
942: p_current_phase,
943: r_migration_data.migration_id);
944: hr_dm_gen_main.post_generate_validate(r_migration_data.migration_id);
945: END IF;
945: END IF;
946:
947: IF (p_current_phase = 'C') THEN
948: -- set current processing
949: hr_dm_utility.set_process('Post-processing',
950: p_current_phase,
951: r_migration_data.migration_id);
952: hr_dm_cleanup.post_cleanup_process(r_migration_data);
953: END IF;
977:
978:
979: END IF;
980:
981: hr_dm_utility.message('INFO','Master concurrent program', 15);
982: hr_dm_utility.message('SUMM','Master concurrent program', 20);
983: hr_dm_utility.message('ROUT','exit:hr_dm_master.master', 25);
984: hr_dm_utility.message('PARA','(none)', 30);
985:
978:
979: END IF;
980:
981: hr_dm_utility.message('INFO','Master concurrent program', 15);
982: hr_dm_utility.message('SUMM','Master concurrent program', 20);
983: hr_dm_utility.message('ROUT','exit:hr_dm_master.master', 25);
984: hr_dm_utility.message('PARA','(none)', 30);
985:
986:
979: END IF;
980:
981: hr_dm_utility.message('INFO','Master concurrent program', 15);
982: hr_dm_utility.message('SUMM','Master concurrent program', 20);
983: hr_dm_utility.message('ROUT','exit:hr_dm_master.master', 25);
984: hr_dm_utility.message('PARA','(none)', 30);
985:
986:
987:
980:
981: hr_dm_utility.message('INFO','Master concurrent program', 15);
982: hr_dm_utility.message('SUMM','Master concurrent program', 20);
983: hr_dm_utility.message('ROUT','exit:hr_dm_master.master', 25);
984: hr_dm_utility.message('PARA','(none)', 30);
985:
986:
987:
988: -- error handling
987:
988: -- error handling
989: EXCEPTION
990: WHEN e_fatal_error THEN
991: hr_dm_utility.error(SQLCODE,'hr_dm_range.master',
992: l_fatal_error_message,'R');
993: report_error(p_current_phase, r_migration_data.migration_id,
994: 'Untrapped error in hr_dm_master.master', 'P');
995: RAISE;
993: report_error(p_current_phase, r_migration_data.migration_id,
994: 'Untrapped error in hr_dm_master.master', 'P');
995: RAISE;
996: WHEN OTHERS THEN
997: hr_dm_utility.error(SQLCODE,'hr_dm_master.master','(none)','R');
998: report_error(p_current_phase, r_migration_data.migration_id,
999: 'Untrapped error in hr_dm_master.master', 'P');
1000: RAISE;
1001: --
1051: l_previous_phase VARCHAR2(30);
1052: l_previous VARCHAR2(30);
1053: e_fatal_error EXCEPTION;
1054: l_fatal_error_message VARCHAR2(200);
1055: r_migration_data hr_dm_utility.r_migration_rec;
1056: l_database_location VARCHAR2(30);
1057: l_request_data VARCHAR2(30);
1058: l_mig_status VARCHAR2(30);
1059:
1080: BEGIN
1081: --
1082:
1083: -- initialize messaging
1084: hr_dm_utility.message_init;
1085:
1086: hr_dm_utility.message('ROUT','entry:hr_dm_master.main_controller', 5);
1087: hr_dm_utility.message('PARA','(p_migration_id - ' ||
1088: p_migration_id || ')', 10);
1082:
1083: -- initialize messaging
1084: hr_dm_utility.message_init;
1085:
1086: hr_dm_utility.message('ROUT','entry:hr_dm_master.main_controller', 5);
1087: hr_dm_utility.message('PARA','(p_migration_id - ' ||
1088: p_migration_id || ')', 10);
1089:
1090:
1083: -- initialize messaging
1084: hr_dm_utility.message_init;
1085:
1086: hr_dm_utility.message('ROUT','entry:hr_dm_master.main_controller', 5);
1087: hr_dm_utility.message('PARA','(p_migration_id - ' ||
1088: p_migration_id || ')', 10);
1089:
1090:
1091: -- see if this is a migration run (l_request_data = NULL)
1092: -- OR
1093: -- is it a restart after slaves have finished? (l_request_data =
1094: -- paused phase code)
1095: l_request_data := fnd_conc_global.request_data;
1096: hr_dm_utility.message('INFO','Request data - ' || l_request_data, 12);
1097:
1098: -- initialize main controller data
1099: controller_init(p_migration_id,
1100: r_migration_data,
1127:
1128: -- does it apply?
1129: IF (INSTR(l_database_location, r_migration_data.database_location) >0) THEN
1130:
1131: hr_dm_utility.message('INFO','Current phase is ' || l_phase_name, 11);
1132: hr_dm_utility.message('INFO','Request data - ' ||
1133: NVL(l_request_data, '?'), 12);
1134:
1135: -- store the previous phase that applies
1128: -- does it apply?
1129: IF (INSTR(l_database_location, r_migration_data.database_location) >0) THEN
1130:
1131: hr_dm_utility.message('INFO','Current phase is ' || l_phase_name, 11);
1132: hr_dm_utility.message('INFO','Request data - ' ||
1133: NVL(l_request_data, '?'), 12);
1134:
1135: -- store the previous phase that applies
1136: l_previous_phase := l_previous;
1133: NVL(l_request_data, '?'), 12);
1134:
1135: -- store the previous phase that applies
1136: l_previous_phase := l_previous;
1137: hr_dm_utility.message('INFO','Previous phase is ' || l_previous_phase, 11);
1138:
1139:
1140:
1141: -- is it completed or not awoken?
1139:
1140:
1141: -- is it completed or not awoken?
1142: -- if not, then run appropriate phase code
1143: IF ((hr_dm_utility.get_phase_status(l_phase_name, p_migration_id) <> 'C')
1144: OR (NVL(l_request_data, '?') <> '?')) THEN
1145:
1146: -- call generic master code
1147: IF (l_phase_name IN ('G', 'R', 'DA', 'DP', 'UA', 'UP', 'D', 'C')) THEN
1149: ELSE
1150: -- call non-generic master code
1151: IF (l_phase_name = 'I') THEN
1152: -- set current processing
1153: hr_dm_utility.set_process('Single threaded',
1154: l_phase_name,
1155: r_migration_data.migration_id);
1156: hr_dm_init.main(r_migration_data);
1157: ELSIF (l_phase_name = 'CP') THEN
1156: hr_dm_init.main(r_migration_data);
1157: ELSIF (l_phase_name = 'CP') THEN
1158: -- mark copy as started
1159: -- set current processing
1160: hr_dm_utility.set_process('Single threaded',
1161: l_phase_name,
1162: r_migration_data.migration_id);
1163: hr_dm_utility.update_phases(p_new_status => 'S',
1164: p_id => hr_dm_utility.get_phase_id('CP'
1159: -- set current processing
1160: hr_dm_utility.set_process('Single threaded',
1161: l_phase_name,
1162: r_migration_data.migration_id);
1163: hr_dm_utility.update_phases(p_new_status => 'S',
1164: p_id => hr_dm_utility.get_phase_id('CP'
1165: , r_migration_data.migration_id));
1166: -- perform source copy on source database only
1167: IF (r_migration_data.database_location = 'S') THEN
1160: hr_dm_utility.set_process('Single threaded',
1161: l_phase_name,
1162: r_migration_data.migration_id);
1163: hr_dm_utility.update_phases(p_new_status => 'S',
1164: p_id => hr_dm_utility.get_phase_id('CP'
1165: , r_migration_data.migration_id));
1166: -- perform source copy on source database only
1167: IF (r_migration_data.database_location = 'S') THEN
1168: hr_dm_copy.source_copy(r_migration_data.migration_id,
1169: r_migration_data.last_migration_date);
1170: END IF;
1171: -- now let the user proceed with the manual copy,
1172: -- so mark the current migration as complete (on source database)
1173: hr_dm_utility.update_phases(p_new_status => 'C',
1174: p_id => hr_dm_utility.get_phase_id('CP'
1175: , r_migration_data.migration_id));
1176: -- and then the user must update the status to complete when manual copy
1177: -- process has been completed
1170: END IF;
1171: -- now let the user proceed with the manual copy,
1172: -- so mark the current migration as complete (on source database)
1173: hr_dm_utility.update_phases(p_new_status => 'C',
1174: p_id => hr_dm_utility.get_phase_id('CP'
1175: , r_migration_data.migration_id));
1176: -- and then the user must update the status to complete when manual copy
1177: -- process has been completed
1178: END IF;
1184: l_request_data := fnd_conc_global.request_data;
1185: EXIT WHEN NVL(l_request_data, '?') <> '?';
1186:
1187: -- did it complete? if not then update status and raise an error
1188: IF (hr_dm_utility.get_phase_status(l_phase_name, p_migration_id)
1189: <> 'C') THEN
1190: -- update status of migration to error
1191: hr_dm_utility.update_migrations(p_new_status => 'E',
1192: p_id => p_migration_id);
1187: -- did it complete? if not then update status and raise an error
1188: IF (hr_dm_utility.get_phase_status(l_phase_name, p_migration_id)
1189: <> 'C') THEN
1190: -- update status of migration to error
1191: hr_dm_utility.update_migrations(p_new_status => 'E',
1192: p_id => p_migration_id);
1193: COMMIT;
1194: -- raise error
1195: l_fatal_error_message := 'Error in ' || l_phase_name || ' phase';
1239: COMMIT;
1240: END IF;
1241:
1242:
1243: hr_dm_utility.message('INFO','Main controller', 15);
1244: hr_dm_utility.message('SUMM','Main controller', 20);
1245: hr_dm_utility.message('ROUT','exit:hr_dm_master.main_controller', 25);
1246: hr_dm_utility.message('PARA','(retcode - ' || retcode ||
1247: ')(errbuf - ' || errbuf || ')', 30);
1240: END IF;
1241:
1242:
1243: hr_dm_utility.message('INFO','Main controller', 15);
1244: hr_dm_utility.message('SUMM','Main controller', 20);
1245: hr_dm_utility.message('ROUT','exit:hr_dm_master.main_controller', 25);
1246: hr_dm_utility.message('PARA','(retcode - ' || retcode ||
1247: ')(errbuf - ' || errbuf || ')', 30);
1248:
1241:
1242:
1243: hr_dm_utility.message('INFO','Main controller', 15);
1244: hr_dm_utility.message('SUMM','Main controller', 20);
1245: hr_dm_utility.message('ROUT','exit:hr_dm_master.main_controller', 25);
1246: hr_dm_utility.message('PARA','(retcode - ' || retcode ||
1247: ')(errbuf - ' || errbuf || ')', 30);
1248:
1249:
1242:
1243: hr_dm_utility.message('INFO','Main controller', 15);
1244: hr_dm_utility.message('SUMM','Main controller', 20);
1245: hr_dm_utility.message('ROUT','exit:hr_dm_master.main_controller', 25);
1246: hr_dm_utility.message('PARA','(retcode - ' || retcode ||
1247: ')(errbuf - ' || errbuf || ')', 30);
1248:
1249:
1250: -- error handling
1252: WHEN e_fatal_error THEN
1253: retcode := 2;
1254: errbuf := 'An error occurred during the migration - examine logfiles' ||
1255: ' for detailed reports.';
1256: hr_dm_utility.error(SQLCODE,'hr_dm_range.main_controller',
1257: l_fatal_error_message,'R');
1258: report_error(l_phase_name, p_migration_id,
1259: l_fatal_error_message || ' in hr_dm_master.main_controller',
1260: 'M');
1261: WHEN OTHERS THEN
1262: retcode := 2;
1263: errbuf := 'An error occurred during the migration - examine logfiles' ||
1264: ' for detailed reports.';
1265: hr_dm_utility.error(SQLCODE,'hr_dm_master.main_controller','(none)','R');
1266: report_error(l_phase_name, p_migration_id,
1267: 'Untrapped error in hr_dm_master.main_controller', 'M');
1268:
1269: --