rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\ciatt.hpb 1.1 1998/05/28 16:04:32 mfrobins Exp $ rem Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem ciatt.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem stlyon 20/10/02 - B2101860 - Default maximum length not required for varchar2 attributes Rem jwetherb 10/12/94 - Add ciiutl.delete_element() Rem jwetherb 09/14/94 - Creation REM *************************************************************************** REM Hand-carved package body for ATTRIBUTE created on 13-SEP-94 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihatt IS -- Generic post-process routines PROCEDURE check_delete(id number); --#BEGIN -- Type-specific routines PROCEDURE assign_derived_values(pl in out NOCOPY cioattribute.data); PROCEDURE assign_domain_properties(domain_reference number, format out varchar2,max_length out number,precision out number); --#END sac_type constant varchar2(6) := 'ATT'; pac_type constant varchar2(6) := 'ENT'; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY cioattribute.data) IS BEGIN -- Access rights for attribute derive from the entity -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pl.v.entity_reference,pac_type, -- 'UPD','SHR'); -- Validate user-defined properties if cieval.is_extended then cieval.check_element(id,pl.v.types,(operation='UPD') ,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; -- Initialize unassigned properties with default values on INSERT if operation = 'INS' then pl.v.element_type_name := sac_type; pl.i.element_type_name := true; /* B2101860 : It is not mandatory to specify a maximum_length for VARCHAR2 attributes (unlike columns). Therefore, the following not only fails because pl.i.maximum_length = false when it should be true (dodgy code in generated maintain() procedures), but it is uneccessary. -- Default length for VARCHAR2 on insert (as for columns) if pl.v.format = 'VARCHAR2' and pl.i.maximum_length = false then pl.v.maximum_length := 240; pl.i.maximum_length := true; end if; */ end if; --#BEGIN assign_derived_values(pl); --#END END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- Access rights for attribute derive from the entity -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(id,sac_type,operation,'SAC'); -- 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 cioattribute.data) IS BEGIN null; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS BEGIN if operation = 'DEL' then -- Delete the attribute and all it's related sub-bits ciiutl.delete_element(id,sac_type); --#BEGIN -- This update moved to ciutl.ipb -- Nullify associations to this att via EL_SRCAREF --update ci_columns --set source_attribute_reference = null --where source_attribute_reference = post_process.id; --#END 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 -- %0!s: Cannot delete -- attribute is used in a unique identifier entry -- %0!s: Cannot delete -- attribute is used by an event END; --#BEGIN --========================= ASSIGN DERIVED VALUES ===========================-- PROCEDURE assign_derived_values(pl in out NOCOPY cioattribute.data) IS assertion_name varchar2(30); BEGIN -- Default the usage properties if the optional_flag is set if pl.i.optional_flag then if pl.v.optional_flag = 'N' then pl.v.option_condition := null; pl.i.option_condition := true; pl.v.initial_usage := 100; pl.v.average_usage := 100; elsif pl.v.optional_flag = 'Y' then if pl.i.initial_usage = false then pl.v.initial_usage := 50; end if; if pl.i.average_usage = false then pl.v.average_usage := 50; end if; end if; pl.i.initial_usage := true; pl.i.average_usage := true; end if; -- Assign the domain properties (format, maximum_length, precision) if the -- domain_reference is being assigned if pl.i.domain_reference and pl.v.domain_reference is not null then assign_domain_properties(pl.v.domain_reference,pl.v.format, pl.v.maximum_length,pl.v.precision); ciiutl.adjust_datatype_sizes(pl.v.id,'ATT',pl.v.format,pl.v.maximum_length, pl.v.precision,'DATA_FORMAT',pl.v.average_length); pl.i.format := true; pl.i.maximum_length := true; pl.i.precision := true; -- Otherwise, if datatype format and sizes are provided, adjust the sizes -- to make them consistent elsif pl.i.format or pl.i.maximum_length or pl.i.precision or pl.i.average_length then ciiutl.adjust_datatype_sizes(pl.v.id,'ATT',pl.v.format,pl.v.maximum_length, pl.v.precision,'DATA_FORMAT',pl.v.average_length); pl.i.maximum_length := true; pl.i.precision := true; -- Check to make sure that the new values still match the domain if pl.v.domain_reference is not null then declare dom_format varchar2(70); dom_maximum_attribute_length number(6); dom_attribute_precision varchar2(4); begin select format,maximum_attribute_length,attribute_precision into dom_format,dom_maximum_attribute_length,dom_attribute_precision from ci_domains where id = pl.v.domain_reference; if check_domain(pl.v.domain_reference,pl.v.format,dom_format, pl.v.maximum_length,dom_maximum_attribute_length, pl.v.precision,dom_attribute_precision) = false then -- Post a warning that the attribute is being dissociated from the -- domain assertion_name := 'CIHATTE_DOM_DISSOC'; rmman.record_check(assertion_name,pl.v.id,null,null,false,'Y', ciiutl.identify(pl.v.id, pl.v.types), ciiutl.identify(pl.v.domain_reference, 'DOM')); pl.v.domain_reference := null; pl.i.domain_reference := true; end if; exception when no_data_found then null; end; end if; end if; END; --======================= ASSIGN DOMAIN PROPERTIES ==========================-- PROCEDURE assign_domain_properties(domain_reference number, format out varchar2,max_length out number,precision out number) IS BEGIN select max(ci.format),max(ci.maximum_attribute_length), max(ci.attribute_precision) into format,max_length,precision from ci_domains ci where ci.id = assign_domain_properties.domain_reference; END; --============================== CHECK DOMAIN ===============================-- FUNCTION check_domain(domain_reference number, format varchar2,dom_format varchar2, maximum_length number,dom_maximum_attribute_length number, precision number,dom_attribute_precision number) RETURN boolean IS BEGIN return(domain_reference is null or (((format is null and dom_format is null) or format = dom_format) and ((maximum_length is null and dom_maximum_attribute_length is null) or maximum_length = dom_maximum_attribute_length) and ((precision is null and dom_attribute_precision is null) or precision = dom_attribute_precision))); END; --#END --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /