REM *************************************************************************** REM Hand-carved package body for ORGANIZATION UNIT created on 16-OCT-98 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihorg IS -- Generic post-process routines PROCEDURE check_delete(id number); pac_type constant varchar2(6) := 'ORG'; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY cioorganization_unit.data) IS BEGIN -- Access control checks -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pl.v.id,pac_type,operation,'SHR'); -- Initialize unassigned properties with default values on INSERT if operation = 'INS' then pl.v.element_type_name := pac_type; pl.i.element_type_name := true; end if; -- The System ORG gets inserted by RAU during Initialization pl.v.system_element_flag := 'N'; pl.i.system_element_flag := true; END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- if operation is 'DELETE', make sure no non-cascading references exist if operation = 'DEL' then check_delete(id); end if; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id number, pl cioorganization_unit.data) IS BEGIN if operation = 'INS' then ciiutl.create_appxxx(pac_type,pl.v.id,pl.v.name); if pl.v.organization_unit_reference is null then -- OrganiZation Unit Ref may not be null ciierr.fatal(1426, ciiutl.identify(pl.v.id, pl.v.types)); end if; else if pl.v.organization_unit_reference is null then -- Cannot update System ORG ciierr.fatal(1424, ciiutl.identify(pl.v.id, pl.v.types)); end if; if pl.i.name and operation = 'UPD' then cioapp_con_interface.traverse('CIHAPPCONU1',id,'APPORG'); end if; end if; if operation = 'INS' or operation = 'UPD' and pl.i.organization_unit_reference then rmman.log_change('CIHORGE_LOOP_CHECK',pl.v.id); end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS BEGIN if operation = 'DEL' then -- Delete the organization unit and all it's related sub-bits ciiutl.delete_element(id,pac_type); end if; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id number) IS dummy number; error_count number := 0; BEGIN null; -- 4.0.12 Removed all simple delete checking -- Check if this organization unit is connected to other application systems -- This is now covered by the delete triggers, but why delete a specifically helpful -- error message? select count(*) into dummy from ci_organization_units org where org.organization_unit_reference = check_delete.id; if dummy > 0 then -- Cannot delete Org Units with children ciierr.post(1427,ciiutl.identify(id, 'ORG')); error_count := 1; end if; select max(org.organization_unit_reference) into dummy from ci_organization_units org where org.irid = check_delete.id; if dummy is null then -- Cannot delete System ORG ciierr.post(1425, ciiutl.identify(id, 'ORG')); error_count := 1; end if; if error_count > 0 then raise cdapi.apierror; end if; END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /