DBA Data[Home] [Help]

PACKAGE: APPS.RCI_ORG_CERT_ETL_PKG

Source


1 PACKAGE RCI_ORG_CERT_ETL_PKG AUTHID CURRENT_USER AS
2 --$Header: rciocrtetls.pls 120.6.12000000.1 2007/01/16 20:46:17 appldev ship $
3 
4 ---12.30.2005 npanandi: added new version of initial load and obsoleted original one
5 PROCEDURE initial_load(
6    errbuf    IN OUT NOCOPY  VARCHAR2
7   ,retcode   IN OUT NOCOPY  NUMBER);
8 
9 PROCEDURE initial_load_obsolete(
10    errbuf    IN OUT NOCOPY  VARCHAR2
11   ,retcode   IN OUT NOCOPY  NUMBER);
12 
13 ---12.30.2005 npanandi: added new version of incremental load and obsoleted original one
14 PROCEDURE incr_load(
15    errbuf  IN OUT NOCOPY VARCHAR2
16   ,retcode IN OUT NOCOPY NUMBER);
17 
18 PROCEDURE incr_load_obsolete(
19    errbuf  IN OUT NOCOPY VARCHAR2
20   ,retcode IN OUT NOCOPY NUMBER);
21 
22 FUNCTION get_last_run_date ( p_fact_name VARCHAR2) RETURN DATE;
23 
24 FUNCTION err_mesg (
25    p_mesg      IN VARCHAR2
26   ,p_proc_name IN VARCHAR2 DEFAULT NULL
27   ,p_stmt_id   IN NUMBER DEFAULT -1) RETURN VARCHAR2 ;
28 
29 PROCEDURE check_initial_load_setup (
30    x_global_start_date OUT NOCOPY DATE
31   ,x_rci_schema 	   OUT NOCOPY VARCHAR2);
32 
33 ----this is to determine number of processes with ineffective controls
34 ---so need processId as a parameter
35    cursor c_proc_w_ineff_ctrls (p_fin_certification_id in number
36                                ,p_organization_id in number
37 							   ,p_process_id in number) is
38       /*12.30.2005 npanandi: changed below query according to changes
39 	               in datamodel for financial statements */
40       select 1 from dual where exists /*select count(process_id) from*/ (
41 	     SELECT DISTINCT ctrls.pk1 as certification_id /*fin_certification_id*/
42       	 	   ,o.organization_id
43 			   ,ctrls.pk3
44                ---,all_ctrls.control_id
45 		       ,op.audit_result_code
46 			   ,op.authored_by
47 			   ,op.authored_date
48 		  	   /*,(select aov.opinion_value_id from AMW_OPINION_LOG_DETAILS aod, AMW_OPINION_VALUES_TL aov
49 	           	  WHERE aov.language=userenv('LANG') and op.OPINION_LOG_ID = aod.OPINION_LOG_ID
50 			   	  	and aod.OPINION_VALUE_ID = aov.OPINION_VALUE_ID
51 			   		and aod.OPINION_COMPONENT_ID = (select OPINION_COMPONENT_ID from AMW_OPINION_COMPONTS_B
52 	                                               	 where OBJECT_OPINION_TYPE_ID = op.OBJECT_OPINION_TYPE_ID
53 												  	   and OPINION_COMPONENT_CODE = 'OPERATING')) op_eff_id
54 	      	   ,(select aov.opinion_value_id from AMW_OPINION_LOG_DETAILS aod, AMW_OPINION_VALUES_TL aov
55 	           	  WHERE aov.language=userenv('LANG') and op.OPINION_LOG_ID = aod.OPINION_LOG_ID
56 			   	    and aod.OPINION_VALUE_ID = aov.OPINION_VALUE_ID
57 			   		and aod.OPINION_COMPONENT_ID = (select OPINION_COMPONENT_ID from AMW_OPINION_COMPONTS_B
58 	                                                 where OBJECT_OPINION_TYPE_ID = op.OBJECT_OPINION_TYPE_ID
59 												  	   and OPINION_COMPONENT_CODE = 'DESIGN')) des_eff_id
60                  ***/
61 	       FROM AMW_CONTROL_ASSOCIATIONS ctrls,
62 	            AMW_CONTROLS_ALL_VL all_ctrls,
63 		        HR_ALL_ORGANIZATION_UNITS o,
64 		        HR_ALL_ORGANIZATION_UNITS_TL otl,
65 		        AMW_OPINIONS_LOG_V op
66 		  WHERE ctrls.object_type = 'RISK_FINCERT'
67 		    and ctrls.control_rev_id = all_ctrls.control_rev_id
68 		    and all_ctrls.APPROVAL_STATUS = 'A'
69 		    and o.organization_id = ctrls.pk2
70 		    and o.organization_id = otl.organization_id
71 		    and otl.language = userenv('LANG')
72 		    and op.opinion_log_id(+)  = ctrls.pk5
73 		    and op.AUDIT_RESULT_CODE <> 'EFFECTIVE'
74 		    AND ctrls.pk1 = p_fin_certification_id
75 		    and o.ORGANIZATION_ID = p_organization_id
76 			and ctrls.pk3 = p_process_id
77 
78 			/**
79 		select distinct aov2.pk2_value ---project_id
80       ,aca.pk1 ----fin_certified_id
81       ,haou.organization_id
82       ,alrv.process_id
83       ,aov1.audit_result_code ---certification_result_code
84       ,aov1.authored_by ----certified_by_id
85       ,aov2.audit_result_code -----evaluation_result_code
86       ,aov2.authored_by -----last_evaluated_by_id
87       ,aov2.authored_date -----last_evaluated_on
88   from amw_control_associations aca
89       ,amw_opinions_log_v aolv
90       ,amw_latest_revisions_v alrv
91       ,HR_ALL_ORGANIZATION_UNITS haou
92       ,HR_ALL_ORGANIZATION_UNITS_TL haout
93       ,amw_opinions_v aov1
94       ,amw_opinions_v aov2
95       ,amw_certification_b acb
96  where aca.object_type='RISK_FINCERT'
97    and aca.pk5=aolv.opinion_log_id
98    and aca.pk3=alrv.process_id
99    and aca.pk2=haou.organization_id
100    and haou.organization_id=haout.organization_id
101    and haout.language=userenv('LANG')
102    and aov1.opinion_type_code='CERTIFICATION'
103    and aov1.AUDIT_RESULT_CODE <> 'EFFECTIVE'
104    and aov1.object_name='AMW_ORG_PROCESS'
105    and aov1.pk1_value=alrv.process_id
106    and aov1.pk3_value=aca.pk2
107    and aov2.opinion_type_code='EVALUATION'
108    and aov2.object_name='AMW_ORG_PROCESS'
109    and aov2.pk1_value=alrv.process_id
110    and aov2.pk3_value=aca.pk2
111    and aca.pk1=acb.certification_id
112    and aov2.authored_date in (select max(aov.authored_date)
113                        from AMW_OPINIONS aov
114                        where aov.object_opinion_type_id = aov2.object_opinion_type_id
115                        and aov.pk1_value = aov2.pk1_value
116                        and aov.pk3_value = aov2.pk3_value)
117    and aca.pk1 = p_fin_certification_id and aca.pk2 = p_organization_id	and aov1.pk1_value = p_process_id
118     **/);
119 
120 
121 ---this is to determine the total number of ineffective controls, regardless
122 ---of whether process is there or not, so don't need processId here
123 ----01/03/2006 npanandi: new query for IneffectiveControls to conform to count columns
124    cursor c_ineffective_ctrls(p_certification_id in number,p_organization_id in number) is
125       select count(control_id) from (
126 	     SELECT DISTINCT ctrls.pk1 as certification_id /*fin_certification_id*/
127       	 	   ,o.organization_id
128                ,all_ctrls.control_id
129 		       ,op.audit_result_code
130 			   ,op.authored_by /*last_evaluated_by_id*/
131 			   ,op.authored_date /*last_evaluated_on*/
132 		  	   ,(select /*aov.OPINION_VALUE_NAME*/ aov.opinion_value_id from AMW_OPINION_LOG_DETAILS aod, AMW_OPINION_VALUES_TL aov
133 	           	  WHERE aov.language=userenv('LANG') and op.OPINION_LOG_ID = aod.OPINION_LOG_ID
134 			   	  	and aod.OPINION_VALUE_ID = aov.OPINION_VALUE_ID
135 			   		and aod.OPINION_COMPONENT_ID = (select OPINION_COMPONENT_ID from AMW_OPINION_COMPONTS_B
136 	                                               	 where OBJECT_OPINION_TYPE_ID = op.OBJECT_OPINION_TYPE_ID
137 												  	   and OPINION_COMPONENT_CODE = 'OPERATING')) op_eff_id
138 	      	   ,(select /*aov.OPINION_VALUE_NAME*/ aov.opinion_value_id from AMW_OPINION_LOG_DETAILS aod, AMW_OPINION_VALUES_TL aov
139 	           	  WHERE aov.language=userenv('LANG') and op.OPINION_LOG_ID = aod.OPINION_LOG_ID
140 			   	    and aod.OPINION_VALUE_ID = aov.OPINION_VALUE_ID
141 			   		and aod.OPINION_COMPONENT_ID = (select OPINION_COMPONENT_ID from AMW_OPINION_COMPONTS_B
142 	                                                 where OBJECT_OPINION_TYPE_ID = op.OBJECT_OPINION_TYPE_ID
143 												  	   and OPINION_COMPONENT_CODE = 'DESIGN')) des_eff_id
144 	       FROM AMW_CONTROL_ASSOCIATIONS ctrls,
145 	            AMW_CONTROLS_ALL_VL all_ctrls,
146 		        HR_ALL_ORGANIZATION_UNITS o,
147 		        HR_ALL_ORGANIZATION_UNITS_TL otl,
148 		        AMW_OPINIONS_LOG_V op
149 		  WHERE ctrls.object_type = 'RISK_FINCERT'
150 		    and ctrls.control_rev_id = all_ctrls.control_rev_id
151 		    and all_ctrls.APPROVAL_STATUS = 'A'
152 		    and o.organization_id = ctrls.pk2
153 		    and o.organization_id = otl.organization_id
154 		    and otl.language = userenv('LANG')
155 		    and op.opinion_log_id(+)  = ctrls.pk5
156 		    and op.AUDIT_RESULT_CODE <> 'EFFECTIVE'
157 		    AND ctrls.pk1 = p_certification_id
158 		    and o.ORGANIZATION_ID = p_organization_id);
159 
160 ----01/03/2006 npanandi: old query
161 /****
162    cursor c_ineffective_ctrls(c_certification_id in number
163                              ,c_organization_id in number) is
164       select count(1) from (
165          SELECT DISTINCT opinionstable.pk2_value as proj_id,
166                 ctrlassoc.pk1 as cert_id,
167                 orgtable.organization_id as org_id,
168 	            ctrlassoc.pk3 as process_id,
169 	            controltable.control_id as ctrl_id,
170 	            opinionstable.audit_result as eval,
171 	            ctrlassoc.control_rev_id as ctrl_rev_id,
172 	            opinionstable.audit_result_code as audit_result_code
173            FROM amw_control_associations ctrlassoc,
174                 amw_controls_all_vl controltable,
175                 amw_audit_units_v orgtable,
176                 amw_opinions_log_v opinionstable,
177                 amw_execution_scope execs,
178                 AMW_PROCESS_ORGANIZATION_VL procorg
179           WHERE execs.entity_id            = ctrlassoc.pk1
180             AND execs.entity_type          = ctrlassoc.object_type
181             AND execs.organization_id      = orgtable.organization_id
182             AND procorg.process_org_rev_id(+) = execs.process_org_rev_id
183             AND ctrlassoc.control_rev_id   = controltable.control_rev_id
184             AND ctrlassoc.pk5              = opinionstable.opinion_log_id (+)
185             AND ctrlassoc.object_type      = 'BUSIPROC_CERTIFICATION'
186             AND ctrlassoc.pk2              = orgtable.organization_id
187             AND nvl(ctrlassoc.pk3,-1)      = nvl(execs.process_id,-1)
188             AND ctrlassoc.pk1              = c_certification_id
189             AND ctrlassoc.pk2              = c_organization_id
190 			and opinionstable.audit_result_code <> 'EFFECTIVE'
191 			and opinionstable.OBJECT_NAME  = 'AMW_ORG_CONTROL'
192 			and opinionstable.OPINION_TYPE_CODE = 'EVALUATION');
193 ***/
194 
195 ---this cursor is used to compute the number of unmitigated risks
196 ---per process, per organization, per certification
197 ---so, depending on the parameters chosen, the numbers will be
198 ---summed up at run-time
199 /*** 01.03.2006 npanandi: changed the below cursor query ***/
200 cursor c_unmitigated_risks(p_certification_id in number,p_organization_id in number) is
201    select count(risk_id) from (
202 
203    SELECT DISTINCT op.pk2_value, /*project_id*/
204 	   /*risks.pk1 as certification_id,*/ /*fin_certification_id*/
205 	   proc.organization_id,
206 	   proc.process_id,
207 	   all_risks.risk_id,
208 	   nvl(all_risks.material,'N'),
209 	   all_risks.risk_impact,
210 	   all_risks.likelihood,
211 	   op.last_updated_by, /*last_evaluator_id*/
212 	   op.authored_date, /*last_evaluated_on*/
213 	   all_risks.risk_rev_id,
214 	   op.audit_result_code
215   FROM AMW_RISK_ASSOCIATIONS risks,
216        AMW_RISKS_ALL_VL all_risks,
217 	   AMW_PROCESS_ORGANIZATION_VL proc,
218 	   HR_ALL_ORGANIZATION_UNITS o,
219        HR_ALL_ORGANIZATION_UNITS_TL otl,
220        AMW_OPINIONS_LOG_V op,
221 	   (select pk1,pk2,NATURAL_ACCOUNT_ID from AMW_ACCT_ASSOCIATIONS where object_type='PROCESS_ORG' and approval_date is not null and deletion_approval_date is null) aaa
222  WHERE risks.object_type = 'PROCESS_FINCERT'
223    and all_risks.risk_rev_id = risks.risk_rev_id
224    and o.organization_id = risks.pk2
225    and o.organization_id = otl.organization_id
226    and otl.language = userenv('LANG')
227    and proc.organization_id = risks.pk2
228    and proc.process_id = risks.pk3
229    and risks.approval_date is not null
230    and proc.approval_status = 'A'
231    and proc.approval_date = risks.approval_date
232    and op.opinion_log_id(+)  = risks.pk4
233    and op.audit_result_code <> 'EFFECTIVE'
234    and risks.pk1 = p_certification_id
235    and proc.organization_id = p_organization_id);
236 
237 /**** original query ***/
238 /****
239 cursor c_unmitigated_risks(c_certification_id in number
240                              ,c_organization_id in number
241 							 ,c_process_id in number) is
242       SELECT count(distinct risk_id) FROM (
243          SELECT DISTINCT assoctable.pk1 cert_id,
244                 orgtable.organization_id as org_id,
245                 assoctable.pk3 as process_id,
246                 assoctable.risk_id as risk_id,
247 		        opinionstable.audit_result as eval,
248 		        procorg.display_name as process_name,
249 		        assoctable.risk_rev_id as risk_rev_id,
250 		        opinionstable.audit_result_code as audit_result_code
251 		   FROM amw_risk_associations assoctable,
252 		        amw_risks_all_vl risktable,
253 		        amw_audit_units_v orgtable,
254 		        amw_opinions_log_v opinionstable,
255 		        amw_execution_scope execs,
256 		        AMW_PROCESS_ORGANIZATION_VL procorg
257 		  WHERE execs.entity_id            = assoctable.pk1
258 		    AND execs.entity_type          = assoctable.object_type
259 		    AND execs.organization_id      = orgtable.organization_id
260 		    AND assoctable.object_type     = 'BUSIPROC_CERTIFICATION'
261 		    AND procorg.process_org_rev_id(+) = execs.process_org_rev_id
262 		    AND assoctable.pk4             = opinionstable.opinion_log_id(+)
263 		    AND assoctable.pk2             = orgtable.organization_id
264 		    AND NVL(assoctable.pk3, -1)    = NVL(execs.process_id,-1)
265 		    AND assoctable.risk_rev_id     = risktable.risk_rev_id
266 		    AND assoctable.pk1             = c_certification_id ---10000 ---:1
267 		    AND assoctable.pk2             = c_organization_id ---5190 ----NVL(:2, assoctable.pk2)
268 		    and assoctable.pk3             = c_process_id ---3045
269 		    and opinionstable.audit_result_code <> 'EFFECTIVE'
270 			and opinionstable.OBJECT_NAME  = 'AMW_ORG_PROCESS_RISK'
271 			and opinionstable.OPINION_TYPE_CODE = 'EVALUATION');
272 ***/
273 
274 ---this cursor is used to compute the number of open issues
275 ---per certification, per organization
276 ---the numbers will be summed up at run-time
277 cursor c_open_org_issues(c_certification_id in number
278                         ,c_organization_id in number) is
279       select /**acv.certification_id
280 	        ,aauv.organization_id
281 			,**/sum(open) as open_issues
282 		from (select change_id,
283 				     change_name,
284 				     description,
285 				     status_type,
286 				     status_code,
287 				     change_order_type_id,
288 				     change_mgmt_type_code,
289 				     initiation_date,
290 				     need_by_date,
291 				     priority_code,
292 				     reason_code,
293 				     (select pk1_value from eng_change_subjects ecs where ecs.entity_name='CERTIFICATION' and ecs.change_id=eec.change_id) certification_id,
294 				     (select pk1_value from eng_change_subjects ecs where ecs.entity_name='ORGANIZATION' and ecs.change_id=eec.change_id) as organization_id,
295 				     (select pk1_value from eng_change_subjects ecs where ecs.entity_name='PROCESS' and ecs.change_id=eec.change_id) as process_id,
296 				     decode(status_code, 0, 0, 11, 0, 1) as open
297 				from eng_engineering_changes eec
298 			   where change_order_type_id in (select change_order_type_id
299 				                                from eng_change_order_types
300 				                               where type_classification='HEADER'
301                                                  and change_mgmt_type_code='AMW_PROC_CERT_ISSUES')) open_issues,
302              amw_audit_units_v aauv,
303 			 amw_certification_vl acv
304 			 ---amw_latest_revisions_v alrv
305        where aauv.organization_id=open_issues.organization_id
306 	     and open_issues.certification_id = acv.certification_id
307 	     ---and open_issues.process_id = alrv.process_id
308 	     and open_issues.certification_id is not null
309 	     and open_issues.organization_id is not null
310 	     ---and open_issues.process_id is null
311 		 and open_issues.certification_id = c_certification_id
312 		 and open_issues.organization_id = c_organization_id
313 	   group by acv.certification_id, aauv.organization_id;
314 
315 
316 /** 01.01.2006 npanandi: added the below 3 cursors for computing
317     processes_certified_with_issues, processes_certified and processes_not_certified
318  **/
319    cursor c_proc_certified_w_issues(p_fin_certification_id in number,p_organization_id in number
320                                    ,p_process_id in number)
321    is
322       select /*count(process_id)*/ 1 from dual where exists (
323 	     select distinct o.organization_id,
324 	   proc.process_id,
325 	   finprocsum.FIN_CERTIFICATION_ID,
326        evalopn.pk2_value, /*project_id*/
327        proc.process_org_rev_id,
328        certopn.audit_result_code, /*certification_result_code*/
329        certopn.authored_by, /*certified_by_id*/
333        evalopn.authored_date /*last_evaluated_on*/
330        certopn.authored_date, /*certified_on*/
331        evalopn.audit_result_code, /*evaluation_result_code*/
332        evalopn.authored_by, /*evaluated_by_id*/
334   from AMW_FIN_CERT_SCOPE finscope,
335        AMW_FIN_PROC_CERT_RELAN REL,
336        AMW_FIN_PROCESS_EVAL_SUM finprocsum,
337        HR_ALL_ORGANIZATION_UNITS o,
338        HR_ALL_ORGANIZATION_UNITS_TL otl,
339        AMW_PROCESS_ORGANIZATION_VL proc,
340        /*AMW_OPINIONS_V*/ AMW_OPINIONS_LOG_V certopn,
341        /*AMW_OPINIONS_V*/ AMW_OPINIONS_LOG_V evalopn
342  where rel.FIN_STMT_CERT_ID = finprocsum.FIN_CERTIFICATION_ID
343    and rel.end_date is null
344    and finprocsum.FIN_CERTIFICATION_ID = finscope.fin_certification_id
345    and finprocsum.ORGANIZATION_ID = finscope.ORGANIZATION_ID
346    and finprocsum.PROCESS_ID  = finscope.PROCESS_ID
347    and finprocsum.PROCESS_ORG_REV_ID = proc.PROCESS_ORG_REV_ID
348    and o.organization_id = finscope.organization_id
349    and o.organization_id = otl.organization_id
350    and otl.language = userenv('LANG')
351    and finprocsum.EVAL_OPINION_LOG_ID = evalopn.opinion_log_id(+)
352    and finprocsum.cert_opinion_log_id = certopn.opinion_log_id(+)
353    and certopn.audit_result_code = 'INEFFECTIVE'
354    and finprocsum.FIN_CERTIFICATION_ID=p_fin_certification_id
355    and finprocsum.ORGANIZATION_ID=p_organization_id
356    and finprocsum.PROCESS_ID=p_process_id);
357 
358    cursor c_proc_certified(p_fin_certification_id in number,p_organization_id in number
359                           ,p_process_id in number)
360    is
361       select /*count(process_id)*/ 1 from dual where exists (
362 	     select distinct o.organization_id,
363 	   proc.process_id,
364 	   finprocsum.FIN_CERTIFICATION_ID,
365        evalopn.pk2_value, /*project_id*/
366        proc.process_org_rev_id,
367        certopn.audit_result_code, /*certification_result_code*/
368        certopn.authored_by, /*certified_by_id*/
369        certopn.authored_date, /*certified_on*/
370        evalopn.audit_result_code, /*evaluation_result_code*/
371        evalopn.authored_by, /*evaluated_by_id*/
372        evalopn.authored_date /*last_evaluated_on*/
373   from AMW_FIN_CERT_SCOPE finscope,
374        AMW_FIN_PROC_CERT_RELAN REL,
375        AMW_FIN_PROCESS_EVAL_SUM finprocsum,
376        HR_ALL_ORGANIZATION_UNITS o,
377        HR_ALL_ORGANIZATION_UNITS_TL otl,
378        AMW_PROCESS_ORGANIZATION_VL proc,
379        /*AMW_OPINIONS_V*/ AMW_OPINIONS_LOG_V certopn,
380        /*AMW_OPINIONS_V*/ AMW_OPINIONS_LOG_V evalopn
381  where rel.FIN_STMT_CERT_ID = finprocsum.FIN_CERTIFICATION_ID
382    and rel.end_date is null
383    and finprocsum.FIN_CERTIFICATION_ID = finscope.fin_certification_id
384    and finprocsum.ORGANIZATION_ID = finscope.ORGANIZATION_ID
385    and finprocsum.PROCESS_ID  = finscope.PROCESS_ID
386    and finprocsum.PROCESS_ORG_REV_ID = proc.PROCESS_ORG_REV_ID
387    and o.organization_id = finscope.organization_id
388    and o.organization_id = otl.organization_id
389    and otl.language = userenv('LANG')
390    and finprocsum.EVAL_OPINION_LOG_ID = evalopn.opinion_log_id(+)
391    and finprocsum.cert_opinion_log_id = certopn.opinion_log_id(+)
392    and certopn.audit_result_code = 'EFFECTIVE'
393    and finprocsum.FIN_CERTIFICATION_ID=p_fin_certification_id
394    and finprocsum.ORGANIZATION_ID=p_organization_id
395    and finprocsum.PROCESS_ID=p_process_id);
396 
397    cursor c_proc_not_certified(p_fin_certification_id in number,p_organization_id in number
398                               ,p_process_id in number)
399    is
400       select /*count(process_id)*/ 1 from dual where exists (
401 	     select distinct o.organization_id,
402 	   proc.process_id,
403 	   finprocsum.FIN_CERTIFICATION_ID,
404        evalopn.pk2_value, /*project_id*/
405        proc.process_org_rev_id,
406        certopn.audit_result_code, /*certification_result_code*/
407        certopn.authored_by, /*certified_by_id*/
408        certopn.authored_date, /*certified_on*/
409        evalopn.audit_result_code, /*evaluation_result_code*/
410        evalopn.authored_by, /*evaluated_by_id*/
411        evalopn.authored_date /*last_evaluated_on*/
412   from AMW_FIN_CERT_SCOPE finscope,
413        AMW_FIN_PROC_CERT_RELAN REL,
414        AMW_FIN_PROCESS_EVAL_SUM finprocsum,
415        HR_ALL_ORGANIZATION_UNITS o,
416        HR_ALL_ORGANIZATION_UNITS_TL otl,
417        AMW_PROCESS_ORGANIZATION_VL proc,
418        /*AMW_OPINIONS_V*/ AMW_OPINIONS_LOG_V certopn,
419        /*AMW_OPINIONS_V*/ AMW_OPINIONS_LOG_V evalopn
420  where rel.FIN_STMT_CERT_ID = finprocsum.FIN_CERTIFICATION_ID
421    and rel.end_date is null
422    and finprocsum.FIN_CERTIFICATION_ID = finscope.fin_certification_id
423    and finprocsum.ORGANIZATION_ID = finscope.ORGANIZATION_ID
424    and finprocsum.PROCESS_ID  = finscope.PROCESS_ID
425    and finprocsum.PROCESS_ORG_REV_ID = proc.PROCESS_ORG_REV_ID
426    and o.organization_id = finscope.organization_id
427    and o.organization_id = otl.organization_id
428    and otl.language = userenv('LANG')
429    and finprocsum.EVAL_OPINION_LOG_ID = evalopn.opinion_log_id(+)
430    and finprocsum.cert_opinion_log_id = certopn.opinion_log_id(+)
431    and certopn.audit_result_code IS NULL
432    and finprocsum.FIN_CERTIFICATION_ID=p_fin_certification_id
433    and finprocsum.ORGANIZATION_ID=p_organization_id
434    and finprocsum.PROCESS_ID=p_process_id);
435 END RCI_ORG_CERT_ETL_PKG;