10: cursor task_c is
11: select attribute1, attribute2, attribute3, attribute4
12: from fii_system_event_log log
13: where log.event_type = 'DNRM:FII_PA_COST_F'
14: and log.event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
15: and log.status = 'PROCESSING';
16:
17: begin
18:
24:
25: update fii_system_event_log log
26: set status = 'PROCESSING'
27: where log.event_type = 'DNRM:FII_PA_COST_F'
28: and log.event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
29: and log.status = 'READY';
30:
31:
32: -- Step 2. remove redundant events from the event log table, i.e. leave only
33: -- the latest event for each task
34:
35: delete from fii_system_event_log log
36: where log.event_type = 'DNRM:FII_PA_COST_F'
37: and log.event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
38: and log.status = 'PROCESSING'
39: and log.event_id not in
40: (
41: select max( event_id )
40: (
41: select max( event_id )
42: from fii_system_event_log log
43: where log.event_type = 'DNRM:FII_PA_COST_F'
44: and log.event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
45: and log.status = 'PROCESSING'
46: );
47:
48: -- Step 3. update log table with task and org data
50: update fii_system_event_log log
51: set (attribute2, attribute3, attribute4) =
52: (
53: select to_char(task.task_pk_key), task.denorm_task_org_fk, to_char(org.organization_pk_key)
54: from edw_proj_task_ltc task,
55: edw_orga_org_ltc org
56: where log.attribute1 = task.task_pk
57: and task.denorm_task_org_fk = org.organization_pk
58: )
56: where log.attribute1 = task.task_pk
57: and task.denorm_task_org_fk = org.organization_pk
58: )
59: where log.event_type = 'DNRM:FII_PA_COST_F'
60: and log.event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
61: and log.status = 'PROCESSING';
62:
63: -- Step 4. update PROJECT_ORG_FK in the fact staging table
64: -- with Task Owning Organization from the Task Level table
66: update fii_pa_cost_fstg fstg
67: set project_org_fk =
68: (
69: select denorm_task_org_fk
70: from edw_proj_task_ltc task
71: where fstg.project_fk = task.task_pk
72: )
73: where fstg.collection_status = 'READY'
74: and fstg.edw_record_type = 'ORACLE';
85: (
86: select attribute3
87: from fii_system_event_log log
88: where log.event_type = 'DNRM:FII_PA_COST_F'
89: and log.event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
90: and log.status = 'PROCESSING'
91: and fstg.project_fk = log.attribute1
92: )
93: where collection_status = 'READY'
96: (
97: select attribute1
98: from fii_system_event_log
99: where event_type = 'DNRM:FII_PA_COST_F'
100: and event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
101: and status = 'PROCESSING'
102: );
103:
104:
115: -- Step 7. delete processed records from the Log table
116:
117: delete from fii_system_event_log
118: where event_type = 'DNRM:FII_PA_COST_F'
119: and event_object = 'EDW_PROJ_TASK_LTC.DENORM_TASK_ORG_FK'
120: and status = 'PROCESSING';
121:
122: -- Step 8. commit changes.
123: