rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\cidom.hpb 1.4 1998/10/09 11:30:00 jkchow Exp $ rem Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem cidom.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem stlyon 22/01/03 - B2670691 : Rem stlyon 20/10/02 - B2101860 - Default maximum length not required for varchar2 attributes Rem loldham 29/09/98 - Bug 700771 - data manipulation not legal on this view Rem jwetherb 10/12/94 - Rebuilt package REM *************************************************************************** REM Hand-carved package body for DOMAIN created on 12-OCT-94 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihdom IS -- Generic post-process routines PROCEDURE check_delete(id number); pac_type constant varchar2(6) := 'DOM'; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY ciodomain.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'); -- 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 := pac_type; pl.i.element_type_name := true; end if; --#BEGIN -- Assign a default DATATYPE if operation = 'INS' then if pl.i.datatype = false and pl.v.datatype is null then select max(ref_parent_code) into pl.v.datatype from ref_values where ref_code = pl.v.format and ref_domain = 'DATA_FORMAT'; if pl.v.datatype is not null then pl.i.datatype := true; end if; end if; -- Assign a default length for VARCHAR2 on insert. if upper(pl.v.datatype) = 'VARCHAR2' and pl.i.maximum_column_length = false then -- B2670691 : Add upper() if pl.v.maximum_column_length is null then -- B1469591 pl.v.maximum_column_length := 240; end if; pl.i.maximum_column_length := true; end if; /* B2101860 : It is not mandatory to specify a maximum_length for VARCHAR2 attributes (unlike columns), so let's not bother. if pl.v.format = 'VARCHAR2' and pl.i.maximum_attribute_length = false then if pl.v.maximum_attribute_length is null then -- B1469591 pl.v.maximum_attribute_length := 240; end if; pl.i.maximum_attribute_length := true; end if; */ end if; -- 4.0.12 config, bug 994810 property supertype_name removed -- If format is null, set average_attribute_length, maximum_attribute_length, -- and attribute_precision = null if pl.v.format is null and (pl.v.average_attribute_length is not null or pl.v.maximum_attribute_length is not null or pl.v.attribute_precision is not null) then pl.v.average_attribute_length := null; pl.i.average_attribute_length := true; pl.v.maximum_attribute_length := null; pl.i.maximum_attribute_length := true; pl.v.attribute_precision := null; pl.i.attribute_precision := true; end if; -- If format, attribute max lengh, or attribute precision are set, check -- that they are valid if pl.i.format or pl.i.maximum_attribute_length or pl.i.attribute_precision or pl.i.average_attribute_length then -- Check that attribute_precision is a valid numeric value declare num number; begin num := pl.v.attribute_precision; exception when others then ciierr.fatal(2013,ciiutl.identify(pl.v.id, pl.v.types),pl.v.attribute_precision); end; ciiutl.adjust_datatype_sizes( pl.v.id, 'DOM', pl.v.format, pl.v.maximum_attribute_length, pl.v.attribute_precision, 'DATA_FORMAT', -- Defines precision and scale rules pl.v.average_attribute_length); pl.i.maximum_attribute_length := true; pl.i.attribute_precision := true; end if; -- If datatype is null, set average_column_length, maximum_column_length, -- and column_precision = null if pl.v.datatype is null and (pl.v.average_column_length is not null or pl.v.maximum_column_length is not null or pl.v.column_precision is not null) then pl.v.average_column_length := null; pl.i.average_column_length := true; pl.v.maximum_column_length := null; pl.i.maximum_column_length := true; pl.v.column_precision := null; pl.i.column_precision := true; end if; -- If datatype, column max lengh, or column precision are set, check -- that they are valid if pl.i.datatype or pl.i.maximum_column_length or pl.i.column_precision or pl.i.average_column_length then -- Check that column_precision is a valid numeric value declare num number; begin num := pl.v.column_precision; exception when others then ciierr.fatal(2013,ciiutl.identify(pl.v.id, pl.v.types),pl.v.column_precision); end; /* B1629816:: 'COL' replaces 'DOM' to ensure that errors recorded for the DATA_FORMAT call to adjust_dataype_sizes don't get removed from table rm_violations by this call when it doesn't find errors in the column datatype. { procedure rmman.record_check() called from ciiutl.adjust_datatype_sizes() deletes from and inserts into table rm_violations using pl.v.id and an id derived from 'COL' or 'DOM' as a key ) */ ciiutl.adjust_datatype_sizes( pl.v.id, 'COL', pl.v.datatype, pl.v.maximum_column_length, pl.v.column_precision, 'DATATYPE', -- B2670691 : DATA_TYPE -> DATATYPE pl.v.average_column_length ); pl.i.maximum_column_length := true; pl.i.column_precision := true; end if; --Convert spaces to underscores in domain name. --if operation='INS' or (operation='UPD' and pl.i.name) then --pl.v.name := translate(pl.v.name,' ','_'); --end if; --#END END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- Access control checks -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(id,pac_type,operation,'SHR'); -- 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 ciodomain.data) IS BEGIN if operation = 'INS' then ciiutl.create_appxxx(pac_type,pl.v.id,pl.v.name); end if; --#BEGIN -- 4.0.12 config, bug 994810 property supertype_name removed -- Check UID 1 if name has changed if operation = 'UPD' and pl.i.name then cioapp_con_interface.traverse('CIHAPPCONU1',pl.v.id,'APPDOM'); end if; /* This may be added in as a future USER PREFERENCE, along with updating DATA ITEM's, COLUMN's, etc. -- If the domain's characteristics change, update all attributes which -- reference this domain if operation in ('INS','UPD') and (pl.i.name or pl.i.format or pl.i.maximum_attribute_length or pl.i.attribute_precision) then for att in (select id,types from ci_attributes where domain_reference = pl.v.id) loop update ci_attributes set format = pl.v.format, maximum_length = pl.v.maximum_attribute_length, precision = pl.v.attribute_precision where id = att.id; end loop; end if; */ --#END END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS BEGIN if operation = 'DEL' then -- Delete the domain 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 -- 4.0.12 Config, Bug 908351 -- Following blocks have been removed from API as now handled by triggers -- Check if this domain is connected to other application systems -- Check if any attributes are connected to me -- Check if any columns are connected to me -- Check if any datastructure items are connected to me -- Check if any module arguments are connected to me -- Check if any program data are connected to me -- Check if any unbound items are connected to me -- Check if any sub-domains are connected to me null; END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /