The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT 1
into l_dummy
FROM SYS.DUAL
WHERE EXISTS (
SELECT NULL
FROM PAY_ASSIGNMENT_ACTIONS ACT
WHERE ACT.PAYROLL_ACTION_ID = p_payroll_action_id)
OR EXISTS (
SELECT NULL
FROM PAY_MESSAGE_LINES PML
WHERE PML.SOURCE_TYPE = 'P'
AND PML.SOURCE_ID = p_payroll_action_id)
OR EXISTS (
SELECT NULL
FROM PAY_POPULATION_RANGES POP
WHERE POP.PAYROLL_ACTION_ID = p_payroll_action_id);
l_pay_act_tab.delete;
l_chunk_num_tab.delete;
l_rand_chunk_num_tab.delete;
select (mod(fnd_crypto.SmallRandomNumber,p_chunk_number-1)+1)
into rand_num
from dual;
update pay_population_ranges
set rand_chunk_number = l_rand_chunk_num_tab(i)
where payroll_action_id = l_pay_act_tab(i)
and chunk_number = l_chunk_num_tab(i);
insert_chunk_statii
Create the rows in chunk status if needed
*/
procedure insert_chunk_statii(p_payroll_action_id in number)
is
begin
--
pay_proc_logging.PY_ENTRY('pay_population_ranges_pkg.insert_chunk_statii');
INSERT into PAY_CHUNK_STATUS
(PAYROLL_ACTION_ID,
CHUNK_NUMBER,
RAND_CHUNK_NUMBER,
POPULATION_STATUS,
PROCESS_STATUS)
SELECT DISTINCT p_payroll_action_id,
CHUNK_NUMBER,
nvl(RAND_CHUNK_NUMBER, CHUNK_NUMBER),
'U',
'U'
FROM pay_population_ranges
WHERE payroll_action_id = p_payroll_action_id;
pay_proc_logging.PY_EXIT('pay_population_ranges_pkg.insert_chunk_statii');
end insert_chunk_statii;
insert_ranges
This is the procedure that actually inserts the ranges, then
performs additional steps (randomisation etc).
*/
procedure insert_ranges(p_payroll_action_id in number,
p_statement in varchar2)
is
type t_curs_ref is ref cursor;
pay_proc_logging.PY_ENTRY('pay_population_ranges_pkg.insert_ranges');
l_pay_act_tab.delete;
l_strt_person_id_tab.delete;
l_end_person_id_tab.delete;
l_chunk_num_tab.delete;
l_rge_stat_tab.delete;
l_person_id_tab.delete;
l_source_id_tab.delete;
l_source_type_tab.delete;
insert into pay_population_ranges (
payroll_action_id,
starting_person_id,
ending_person_id,
chunk_number,
range_status,
person_id,
source_id,
source_type)
values (
l_pay_act_tab(i),
l_strt_person_id_tab(i),
l_end_person_id_tab(i),
l_chunk_num_tab(i),
l_rge_stat_tab(i),
l_person_id_tab(i),
l_source_id_tab(i),
l_source_type_tab(i));
insert into pay_population_ranges (
payroll_action_id,
starting_person_id,
ending_person_id,
chunk_number,
range_status
)
values (
p_payroll_action_id,
l_person_id_tab(1),
l_end_person_id,
chunk_number,
'U'
);
insert_chunk_statii(p_payroll_action_id);
pay_proc_logging.PY_EXIT('pay_population_ranges_pkg.insert_ranges');
end insert_ranges;
pay_proc_environment_pkg.update_pop_action_status(
p_payroll_action_id,
APS_POP_RANGES );
insert_ranges(p_payroll_action_id,
l_statement);
pay_proc_environment_pkg.update_pop_action_status(
p_payroll_action_id,
APS_POP_ACTIONS );
select payroll_action_id,
nvl(rand_chunk_number, chunk_number)
from pay_population_ranges
where payroll_action_id = p_payroll_action_id
and range_status = 'E';
l_pay_act_tab.delete;
l_chunk_num_tab.delete;
delete from pay_action_interlocks pai
where pai.locking_action_id in
(select aa.assignment_action_id
from pay_assignment_actions aa
where payroll_action_id = l_pay_act_tab(i)
and chunk_number = l_chunk_num_tab(i));
delete from pay_assignment_actions aa
where aa.payroll_action_id = l_pay_act_tab(i)
and aa.chunk_number = l_chunk_num_tab(i);
delete from pay_temp_object_actions aa
where aa.payroll_action_id = l_pay_act_tab(i)
and aa.chunk_number = l_chunk_num_tab(i);
update pay_population_ranges ppr
set range_status = 'U'
where ppr.payroll_action_id = l_pay_act_tab(i)
and ppr.chunk_number = l_chunk_num_tab(i);
update pay_chunk_status
set population_status = 'U'
where payroll_action_id = l_pay_act_tab(i)
and chunk_number = l_chunk_num_tab(i);
pay_proc_environment_pkg.update_pop_action_status(
p_payroll_action_id,
APS_POP_ACTIONS );