Vous êtes sur la page 1sur 4

/*

IMPORTANT NOTE
==============
This script can be used ONLY IF the timecard for this period was never retrieved
successfully even once.
INPUT PARAMETERS
================
l_resource_id - person_id of the employee
l_start_time - timecard start time
l_stop_time - timecard stop time
For that particular person, timecard start time, stop time combination, back-end
data is completely removed
and user has to freshly create the timecard. Timestore will not contain any info
rmation for this timecard
and the associated workflows are also aborted. So any pending notifications will
all get cancelled
through this script.
Take a screenshot of this timecard before executing this script, so that it beco
mes easy to recreate the
timecard with the latest data.
Always test this on a debug instance first and only then move it to production.
Steps to follow
===============
1) Take a screenshot of this stuck timecard which was never retrieved to any of
the recipient applications.
2) Generate the OVC
3) Execute this delete script
4) Commit;
5) Generate the OVC and this time the OVC should not contain any data.
6) Create the timecard again, if required
*/
--set serveroutput on;
declare
CURSOR building_block_id_csr (c_resource_id NUMBER,
c_start_time DATE,
c_stop_time DATE) IS
select time_building_block_id
from hxc_time_building_blocks
start with resource_id = c_resource_id
and trunc(start_time) = c_start_time
and trunc(stop_time) = c_stop_time
connect by prior time_building_block_id = parent_building_block_id
and prior object_version_number = parent_building_block_ovn
order by time_building_block_id;
CURSOR app_period_csr (c_resource_id NUMBER,
c_start_time DATE,
c_stop_time DATE) IS
select time_building_block_id
from hxc_time_building_blocks
where scope = 'APPLICATION_PERIOD'
and resource_id in (c_resource_id)
and trunc(start_time) = c_start_time
and trunc(stop_time) = c_stop_time;
TYPE numtab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
tbb_id_tab numtab;
app_period_tab numtab;
l_retrieval_count NUMBER;
l_resource_id NUMBER;
l_start_time DATE;
l_stop_time DATE;
l_item_key wf_items.item_key%TYPE;
/* tting testing.. --*/
TYPE hxc_time_building_blocks_rec IS TABLE OF hxc_time_building_blocks%ROWTYPE
INDEX BY PLS_INTEGER;
hxc_time_building_blocks_recs hxc_time_building_blocks_rec;
/* tting testing.. --*/
begin
dbms_output.put_line('Start processing...');
l_resource_id := 236536;
l_start_time := '30-MAY-2009';
l_stop_time := '12-JUN-2009';
select count(*)
into l_retrieval_count
from hxc_transactions ht, hxc_transaction_details htd
where ht.transaction_id = htd.transaction_id
and ht.type = 'RETRIEVAL'
and ht.status = 'SUCCESS'
and htd.status = 'SUCCESS'
and htd.time_building_block_id in
(select time_building_block_id
from hxc_latest_details
where resource_id in (l_resource_id)
and trunc(start_time) = l_start_time);
dbms_output.put_line('l_retrieval_count = '||l_retrieval_count);
IF (l_retrieval_count <> 0) THEN
dbms_output.put_line('********************************************************
**');
dbms_output.put_line('This timecard has been successfully retrieved atleast on
ce');
dbms_output.put_line('DO NOT USE THIS SCRIPT TO DELETE DATA FOR THIS TIMECARD'
);
dbms_output.put_line('Exiting .....');
dbms_output.put_line('********************************************************
**');
ELSE
OPEN app_period_csr (l_resource_id, l_start_time, l_stop_time);
FETCH app_period_csr BULK COLLECT INTO app_period_tab;
CLOSE app_period_csr;
OPEN building_block_id_csr (l_resource_id, l_start_time, l_stop_time);
FETCH building_block_id_csr BULK COLLECT INTO tbb_id_tab;
CLOSE building_block_id_csr;
dbms_output.put_line('tbb_id_tab.COUNT = '||tbb_id_tab.COUNT);
-- Process TIMECARD, DAY, DETAIL scope building block ids
IF (tbb_id_tab.COUNT > 0) THEN
--1.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
--DELETE FROM hxc_time_building_blocks
update hxc_time_building_blocks
set last_update_date = sysdate
WHERE time_building_block_id = tbb_id_tab(i);
dbms_output.put_line('Updated hxc_time_building_blocks... ');
--2.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE FROM hxc_time_attributes
update hxc_time_attributes
set attribute30 = sysdate
WHERE time_attribute_id IN
(select time_attribute_id from hxc_time_attribute_usages
where time_building_block_id = tbb_id_tab(i));
dbms_output.put_line('Deleted from hxc_time_attributes... ');
--3.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE FROM hxc_time_attribute_usages
update hxc_time_attribute_usages
set last_update_date = sysdate
WHERE time_building_block_id = tbb_id_tab(i);
dbms_output.put_line('Deleted from hxc_time_attribute_usages... ');
--4.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE from hxc_tc_ap_links
update hxc_tc_ap_links
set application_period_id = 666
WHERE timecard_id = tbb_id_tab(i);
dbms_output.put_line('Deleted from hxc_tc_ap_links... ');
--5.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
--DELETE FROM hxc_latest_details
update hxc_latest_details
set last_update_date = sysdate
WHERE time_building_block_id = tbb_id_tab(i);
dbms_output.put_line('Deleted from hxc_latest_details... ');
--6.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE FROM hxc_ap_detail_links
update hxc_ap_detail_links
set time_building_block_ovn = 666
WHERE time_building_block_id = tbb_id_tab(i);
dbms_output.put_line('Deleted from hxc_ap_detail_links... ');
--7.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE from hxc_transactions
update hxc_transactions
set last_update_date = sysdate
WHERE transaction_id in
(select transaction_id from hxc_transaction_details
where time_building_block_id = tbb_id_tab(i));
dbms_output.put_line('Deleted from hxc_transactions... ');
--8.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE from hxc_transaction_details
update hxc_transaction_details
set last_update_date = sysdate
WHERE time_building_block_id = tbb_id_tab(i);
dbms_output.put_line('Deleted from hxc_transaction_details... ');
--9.
FORALL i IN tbb_id_tab.FIRST..tbb_id_tab.LAST
-- DELETE from hxc_timecard_summary
update hxc_timecard_summary
set attribute30 = sysdate
WHERE timecard_id = tbb_id_tab(i);
dbms_output.put_line('Deleted from hxc_timecard_summary... ');
END IF;
dbms_output.put_line('Process the application periods... ');
-- Process the application period scope building block ids
dbms_output.put_line('app_period_tab.COUNT = '||app_period_tab.COUNT);
IF (app_period_tab.COUNT > 0) THEN
--10.
FORALL i IN app_period_tab.FIRST..app_period_tab.LAST
--DELETE FROM hxc_app_period_summary
update hxc_app_period_summary
set creation_date = sysdate
WHERE application_period_id = app_period_tab(i);
dbms_output.put_line('Deleted from hxc_app_period_summary... ');
END IF;
END IF;
end;
--/

Vous aimerez peut-être aussi