rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\CIFUNATT.HPB 1.2 1998/12/30 14:54:36 loldham Exp $ rem Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem cifunatt.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem jwetherb 01/09/95 - Maintain FUNENT_REFERENCE denormalized property Rem aheath 07/08/94 - Creation REM *************************************************************************** REM Hand-carved package body for Function Attribute Usage created on 14-FEB-94 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihfunatt IS -- Type-specific pre-process routines PROCEDURE reconcile_funents(funent_reference rm.reference); -- Type-specific post-process routines PROCEDURE check_delete(id rm.reference); str_type constant varchar2(6) := 'FUNATT'; part_type constant varchar2(6) := 'FUN'; use_type constant varchar2(6) := 'ATT'; function_reference rm.reference; funent_reference rm.reference; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id rm.reference, pl in out NOCOPY ciofunction_attribute_usage.data) IS BEGIN -- Perform INSERT-specific processing if operation = 'INS' then -- Check for existence of function and attribute -- elements if ciiutl.el_exists(pl.v.function_reference,part_type) = false then ciierr.fatal(3500,'FUNCTION ATTRIBUTE USAGE','function', pl.v.function_reference); end if; if ciiutl.el_exists(pl.v.attribute_reference,use_type) = false then ciierr.fatal(3500,'FUNCTION ATTRIBUTE USAGE','attribute', pl.v.attribute_reference); end if ; else if ciiutl.el_exists(id,str_type) = false then ciierr.fatal(3504,ciiutl.nls_type_name('FUNCTION_ATTRIBUTE_USAGE'),id); end if; end if; -- Access control checks -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_pac(pl.v.function_reference,part_type,'UPD'); -- if operation = 'INS' then -- ciiacc.check_access_rights(pl.v.attribute_reference, use_type,'SEL','SAC'); -- end if; -- Check that function attribute usage with this function and -- attribute doesn't already exist on insert -- CHECK REPLACED BY DEFERRED CONSTRAINT AT 4.0.6 if operation = 'INS' then -- Initialize unassigned properties with default values on INSERT -- Assign miscellaneous initial default values pl.v.element_type_name := str_type; pl.i.element_type_name := true; -- Assign the denormalized property ENTITY_REFERENCE select max(entity_reference) into pl.v.entity_reference from ci_attributes where id = pl.v.attribute_reference; if pl.v.entity_reference is not null then pl.i.entity_reference := true; else ciierr.fatal(3500,'FUNCTION ATTRIBUTE USAGE','attribute', pl.v.attribute_reference); end if; -- Assign the denormalized property FUNENT_REFERENCE select max(id) into pl.v.funent_reference from ci_function_entity_usages where entity_reference = pl.v.entity_reference and function_reference = pl.v.function_reference; if not cdapi.load_mode and pl.v.funent_reference is null then declare funent ciofunction_entity_usage.data; begin funent.v.entity_reference := pl.v.entity_reference; funent.i.entity_reference := true; funent.v.function_reference := pl.v.function_reference; funent.i.function_reference := true; ciofunction_entity_usage.ins(null,funent); pl.v.funent_reference := funent.v.id; end; end if; pl.i.funent_reference := true; end if; -- Validate user-defined properties if cieval.is_extended then cieval.check_association(id,pl.v.types,(operation='UPD') ,pl.v.function_reference ,pl.v.attribute_reference ,pl.v.user_defined_property_0,pl.i.user_defined_property_0 ,pl.v.user_defined_property_1,pl.i.user_defined_property_1 ,pl.v.user_defined_property_2,pl.i.user_defined_property_2 ,pl.v.user_defined_property_3,pl.i.user_defined_property_3 ,pl.v.user_defined_property_4,pl.i.user_defined_property_4 ,pl.v.user_defined_property_5,pl.i.user_defined_property_5 ,pl.v.user_defined_property_6,pl.i.user_defined_property_6 ,pl.v.user_defined_property_7,pl.i.user_defined_property_7 ,pl.v.user_defined_property_8,pl.i.user_defined_property_8 ,pl.v.user_defined_property_9,pl.i.user_defined_property_9 ,pl.v.user_defined_property_10,pl.i.user_defined_property_10 ,pl.v.user_defined_property_11,pl.i.user_defined_property_11 ,pl.v.user_defined_property_12,pl.i.user_defined_property_12 ,pl.v.user_defined_property_13,pl.i.user_defined_property_13 ,pl.v.user_defined_property_14,pl.i.user_defined_property_14 ,pl.v.user_defined_property_15,pl.i.user_defined_property_15 ,pl.v.user_defined_property_16,pl.i.user_defined_property_16 ,pl.v.user_defined_property_17,pl.i.user_defined_property_17 ,pl.v.user_defined_property_18,pl.i.user_defined_property_18 ,pl.v.user_defined_property_19,pl.i.user_defined_property_19 ); end if; END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id rm.reference) IS pac_reference rm.reference; BEGIN -- Access rights for a Function Attribute Usage derive from the referenced -- Function's rights -- Access rights checking performed by triggers in config 4.0.9 /* select max(function_reference),max(funent_reference) into cihfunatt.function_reference,cihfunatt.funent_reference from ci_function_attribute_usages where id = pre_process.id; pac_reference := function_reference; if operation = 'DEL' and function_reference is not null then ciiacc.check_pac(pac_reference,part_type,'UPD'); else ciiacc.check_pac(pac_reference,part_type,operation); end if; */ null; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id rm.reference, pl ciofunction_attribute_usage.data) IS BEGIN if operation in ('INS','UPD') then reconcile_funents(pl.v.funent_reference); end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id rm.reference) IS BEGIN if operation = 'DEL' then reconcile_funents(cihfunatt.funent_reference); end if; END; --========================== RECONCILE FUNENTS ==============================-- -- Update the FUNENT if this is the last or first usage of it's type for -- an attribute in this entity against this FUNCTION PROCEDURE reconcile_funents(funent_reference rm.reference) IS funent ciofunction_entity_usage.data; funent_ref rm.reference; funent_update varchar2(1); funent_retrieve varchar2(1); funatt_update varchar2(1); ins_flag varchar2(1); upd_flag varchar2(1); null_flag varchar2(1); ret_flag varchar2(1); BEGIN if cdapi.load_mode then return; end if; -- Get the FUNENT info; if no FUNENT is found, it will be created later select max(id),max(update_flag),max(retrieve_flag) into funent_ref,funent_update,funent_retrieve from ci_function_entity_usages funent where funent.id = reconcile_funents.funent_reference; if funent_ref is null then -- funent_ref will be null during a cascade delete return; end if; -- Get the FUNATT info select max(insert_flag),max(update_flag), max(nullify_flag),max(retrieve_flag) into ins_flag,upd_flag,null_flag,ret_flag from ci_function_attribute_usages where funent_reference = reconcile_funents.funent_reference; funatt_update := nvl(nvl(ins_flag,upd_flag),null_flag); if funent_update = 'Y' and funatt_update is null then funent.v.update_flag := null; funent.i.update_flag := true; elsif funent_update is null and funatt_update = 'Y' then funent.v.update_flag := 'Y'; funent.i.update_flag := true; end if; if funent_retrieve = 'Y' and ret_flag is null then funent.v.retrieve_flag := null; funent.i.retrieve_flag := true; elsif funent_retrieve is null and ret_flag = 'Y' then funent.v.retrieve_flag := 'Y'; funent.i.retrieve_flag := true; end if; if funent.i.update_flag or funent.i.retrieve_flag then ciofunction_entity_usage.upd(funent_ref,funent); end if; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id rm.reference) IS dummy varchar2(1); BEGIN -- Check if non-cascading associations and references exist null; END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /