Professional Documents
Culture Documents
select … from bo_case a, bo_case_stage b where a.caseid = b.caseid and b.stage_name in (…)
or – better - in ANSI SQL syntax:
The filtering on the Case type is required because DW’s m_olaf_cases includes the ones with case
type MISSION.
The BO version will return the results in <4 secs while - despite this required additional filtering - the
DW version returns the same set in < 0.1 secs ( stage_name in (‘INVESTIGATION’,
‘COORDINATION’) as an example).
Support requests
select * from (
select cc.ocas_casenumber_lib as case_number,
mc.ocas_casenumber_lib as linked_case_number,
oclc_unitcode_lib as unit, oclc_stagename_lib as phase,
cc.ocas_status_lib || '/' || cc.ocas_substatus_lib as status,
casf_staff_lib as person_name,
casf_role_lib as role,
ostf_isactive_swi, ostf_ocmactive_swi
from v_an_lc_cases cc
join v_case_lifecycles on oclc_ocas_oid = ocas_oid and oclc_islaststage_swi = 1
union all
where
ca.cact_activitytype_lib in ('ASR', 'LA')
and not exists(select 1 from m_case_child_relactivities where ccrl_cact_oid =
ca.cact_oid)
)
order by to_number(substr(case_number,4,4)), to_number(substr(case_number,9,4)),
substr(case_number,1,2), role, person_name
;
In OCM, the recommendations are linked to the monitoring information from which is then possible
to get the related contacts and the documents and their keywords, and being an object in the Case,
it’s possible to go to the Case life cycle.
As of July 2020, two different models exist in OCM, the oldest one implying that the ROLE of the
associated contact is not filled in. These recommendations will have the ‘TO BE UPDATED (old
model)’ as role. In the new model, only OFFICIAL CONTACT are returned.
The mapping of document titles has been specified as: by default the document’s associated
KEYWORD is used, in case it’s not defined then: all titles containing the RECOMMENDATION word are
mapped as RECOMMENDATION except the RECOMMENDATATION TRANSMISSION which is mapped
as a TRANSMISSION LETTER as all other titles. It’s returned as SUBJECT in the lowest layer of the
query.
In case new titles are defined the view should be updated as per default unknown titles are mapped
to NULL.
From the technical point of view, in order to identify multiple usage of same document, the RID and
the recommendation date must be concatenated with the SUBJECT.
The version _WSD of the view (With Support Document) adds LEFT JOINs on the MONITORING
AMOUNTs.
The v_synth_reco_report_units adds information about the UNIT and the LEAD INVESTIGATOR to the
v_synth_recommendations_wsd view but also outouts the situations where the LEAD INVESTIGATOR
is not defined while the STAGE is post-SELECTION.
restricts the selection of results to activities started before the 1 st of the current month: this
means it will output the same results1 for the whole duration of the month;
uses both PIVOT (and even PIVOT over PIVOT) and CUBE operations making difficult to
reproduce its behaviour with standard reporting tools.
Technically, it’s selecting the different activities of interest in different CTE: the INTERVIEW and
DIGITAL FORENSIC are selected together because they don’t related to other information than Case
and activities, ON THE SPOT CHECK and INSPECTION OF PREMISES have their own CTE to select their
custom information.
v_act_inspections
v_act_onthespotchecks
v_act_digitfas
v_act_interviews
If you need to re-calculate the report at a specific date, the function dyn_rpt_activity_ray(i_rpt_date
IN DATE, i_trunc IN VARCHAR2) RETURN t_rpt_activity_rays will give you the expected result.
The i_trunc parameter is the truncation string used to TRUNC the date.
1
not taking into account independent data quality actions
In DW:
select distinct doca_docu_oid, docu_name_lib,
od.docu_format_lib, od.docu_expedition_dat,
cccx_oid, m_casecontactctx.cccx_contactname_lib, cccx_cont_oid, cccx_org_cont_oid,
pers.cont_name_lib as person_name, pers.cont_source_lib as person_source,
pers.cont_type_lib as person_type, pers.cont_active_swi as person_active,
org.cont_name_lib as org_name, org.cont_source_lib as org_source, org.cont_type_lib as
org_type, org.cont_active_swi as org_active
from m_document2cases
left join m_outgoingdocs od on od.docu_oid = doca_docu_oid
join m_documents doc on doc.docu_oid = doca_docu_oid
join m_document2casecontactctx on dccx_docu_oid = doca_docu_oid
join m_casecontactctx on cccx_oid = dccx_cccx_oid
join m_contacts pers on pers.cont_oid = cccx_cont_oid
left join m_contacts org on org.cont_oid = cccx_org_cont_oid
where doca_ocas_oid in (
…
)
;
Benefits:
number of JOIN operations is reduced and easier to write thanks to naming conventions,
no need to check for acl_name <> ocm_acl_deleted (and so no risk to forget to)
select * from (
select cc.ocas_casenumber_lib as case_number,
mc.ocas_casenumber_lib as linked_case_number,
oclc_unitcode_lib as unit, oclc_stagename_lib as phase,
cc.ocas_status_lib || '/' || cc.ocas_substatus_lib as status,
casf_staff_lib as person_name,
casf_role_lib as role,
ostf_isactive_swi, ostf_ocmactive_swi
from v_an_lc_cases cc
join v_case_lifecycles on oclc_ocas_oid = ocas_oid and oclc_islaststage_swi = 1
join v_case_active_staffs on casf_ocas_oid = ocas_oid
union all
where
ca.cact_activitytype_lib in ('ASR', 'LA')
and not exists(select 1 from m_case_child_relactivities where ccrl_cact_oid =
ca.cact_oid)
)
order by to_number(substr(case_number,4,4)), to_number(substr(case_number,9,4)),
substr(case_number,1,2), role, person_name
;
with data_intv_digitfa as (
select d.*,
null as combined_ostc, null as combined_insp, lc.oclc_unitcode_lib as unit_code
from (
select act.cact_ocas_oid as case_oid, ocas_casenumber_lib as case_number,
act.cact_activitytype_lib as activity_type,
extract(year from reqact.cact_end_rpt_dat) as activity_year
from m_case_activities act
join m_olaf_cases on ocas_oid = cact_ocas_oid
join m_case_parent_activities on cacp_cact_oid = act.cact_oid
join m_case_activities reqact on reqact.cact_oid = cacp_childcact_oid and
reqact.cact_activitytype_lib = 'REQ' and reqact.cact_status_lib ='APPROVED'
where
ocas_casetype_lib in (select * from v_case_prefixes)
and (act.cact_activitytype_lib, act.cact_activitysubtype_lib) in (('INTV', ' '),
('DIGIT_FA', ' ') )
and (act.cact_status_lib not in ('CANCELLED', 'CANCELL', 'REJECTED'))
and (act.cact_start_rpt_dat < (select trunc(sysdate,'MM') from dual))
) d
join v_case_lifecycles lc on lc.oclc_ocas_oid = d.case_oid and lc.oclc_islaststage_swi =
1
)
,data_otsc as (
select d.*, lc.oclc_unitcode_lib as unit_code
from (
Case staffing with UNIT, Phase, Status of the Case and active statuses of the Staff
select
ocas_casenumber_lib as case_number,
oclc_unitcode_lib as unit, oclc_stagename_lib as phase,
ocas_status_lib || ‘/’ ocas_substatus_lib as status,
casf_staff_lib as person_name,
casf_role_lib as role,
ostf_isactive_swi, ostf_ocmactive_swi
from
m_olaf_cases
join v_case_lifecycles on oclc_ocas_oid = ocas_oid
join v_case_active_staffs on casf_ocas_oid = ocas_oid
join m_olaf_staffs on casf_ostf_oid = ostf_oid
where
ocas_casetype_lib in (select * from v_case_prefixes)
and oclc_stagename_lib in ( ‘SELECTION’, ‘INVESTIGATION’, ‘MONITORING’, ‘COORDINATION’)
order by to_number(ocas_casenumber_lib,4,4)), to_number(substr(ocas_casenumber_lib,9,4)),
casf_role_lib, casf_staff_lib
;
1. the complexity of the needs themselves (requiring to PIVOT the intermediary results on an
criteria calculated from different sources, …);
2. the evolution of the data model and the coexistence of different representation (finalisation
by activity or by document with different activity names and statuses according to the type of
the recommendation (financial or judicial), recommendation document linked to the
recommendation object or the related activity, complex assembly of the different sources of
information while avoiding duplicated rows in the results, …);
3. lack of information in pre-OCM data (keyword to identify the nature of the document, …)
requiring fall back technique to find the information (scanning the document title,…);
4. data quality issues due to different factors: user errors or misuse of OCM that could not
further fixed because concerning registered documents (usage of several time the same
recommendation or recommendation document in different Cases, …),
5. technical limitation of the version of ORACLE we are using (the lack of DISTINCT keyword in
LISTAGG, available only from version 19c, …)
6. lack of consistency of name of activities and status/substatus between the different kind of
recommendations
WITH doc_via_reco AS (
SELECT
reco_oid, caob_ocas_oid as ocas_oid,
mong_oid, mong_cact_oid AS mong_mainactivity_oid,
reco_recommendationtype_lib, reco_objectname_lib AS reco_name_lib,
reco_reference_lib, reco_amounttoberecovered_num, reco_amounttobeprevented_num,
mong_status_lib as mong_recommendationoutcome_lib,
doc.docu_registration_lib AS reco_rid, doc.docu_registration_dat as reco_date,
doc.docu_oid, doc.docu_registration_lib, doc.docu_registration_dat,
docu_title_lib as title, doc.docu_savenumber_lib as save_nr,
'RECOMMENDATION' as subject
FROM m_recommendations r
JOIN m_monitoring2recommendations on more_reco_oid = reco_oid
JOIN m_monitorings mon ON more_mong_oid = mong_oid
JOIN m_case_objects on caob_object_oid = reco_oid
JOIN m_doc2recommendations ON docr_reco_oid = r.reco_oid
JOIN m_documents doc on doc.docu_oid = docr_docu_oid
AND INSTR(docu_title_lib, 'ANNULLED DOCUMENT') = 0
),
doc_with_act AS (
SELECT reco_oid, caob_ocas_oid as ocas_oid, mong_oid,
mong_cact_oid AS mong_mainactivity_oid,
reco_recommendationtype_lib, reco_objectname_lib AS reco_name_lib,
reco_reference_lib, reco_amounttoberecovered_num,
reco_amounttobeprevented_num, mong_status_lib as mong_recommendationoutcome_lib,
doc.docu_registration_lib AS reco_rid, doc.docu_registration_dat as reco_date,
doc.docu_oid, doc.docu_registration_lib, doc.docu_registration_dat,
docu_title_lib as title, docu_savenumber_lib as save_nr,
NVL( actdoc_r.dock_keyword_lib,
DECODE (SUBSTR(UPPER(docu_title_lib),1,18),
'ADMINISTRATIVE REC', 'RECOMMENDATION',
'TRANSMISSION LETTE', 'TRANSMISSION LETTER',
'TRANSMISSION NOTE ', 'TRANSMISSION LETTER',
doc_via_reco: collect the document directly linked to the OCM recommendation object, this one is
always the RECOMMENDATION document itself
doc_with_act: collect the documents linked to the OCM activity object, these documents maybe also
TRANSMISSION LETTER
fin_by_act: collect the FINALISATION done by activity instead of a document, the finalisation date will
then be the end date of the approved activity, otherwise it’s the registration date of the document.
the doc_via_reco
+
the doc_with_act that are FINALISATION, RECOMMENDATION or TRANSMISSION LETTER but not
the ones present in doc_via_reco
+
the fin_by_act for which they are no FINALISATION document in the 2 previous subset.
Once we have the final list of documents, we have to assemble the results by JOINing the documents
found with the life cycles of the Case they belong to return the name of the current stage, and with
Because operational situations (or lack of understanding of business rules), have forced the end-
users to use several times the same recommendation in different Cases, we then need to assemble
the results in a way that allows the query to return only one row per (Case, Recommendation) and
this requires a SQL trick (usage of LAG analytical function and taking advantage of the fact that
LISTAGG don’t return NULL values) to get around the fact that we don’t have the DISTINCT option in
the LISTAGG function, and we need it to use to return only 1 row.
Once this operation is done, we can eventually PIVOT the results to make columns out of the
information (registration id, registration date) associated to the different kind of documents
(RECOMMENDATION, FINALISATION, TRANSMISSION).
The latest operation is to link the result to the latest approval information related to the closing
activity of which subtype depends on the kind of recommendation: END for Financial
recommendation and JUDFINAL for Judicial recommendation.
The WSD2 variation of the same view returns also the history the monitoring amount modifications.
For this reason the rule one line per (Case, Recommendation) cannot be respected anymore and the
WSD variant should not be used to aggregate results like the recovered/prevented amounts.
2
The original purpose of the WSD variation was to monitor modifications done by end-users, not to do
operational reporting.