rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\cipco.hpb 1.5 1998/12/14 18:46:58 cvanes Exp $ rem Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem cipco.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem aheath 07/08/94 - Creation REM *************************************************************************** REM Hand-carved package body for PRIMARY KEY CONSTRAINT created on 06-SEP-94 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihpco IS -- Type-specific post-process routines PROCEDURE check_delete(id rm.reference); sac_type constant varchar2(6) := 'OCO'; pac_type constant varchar2(6) := 'TAB'; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id rm.reference, pl in out NOCOPY cioprimary_key_constraint.data) IS BEGIN -- Access rights for primary key constraint derive from the table -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pl.v.table_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; pl.v.constraint_type := 'PRIMARY'; pl.i.constraint_type := true; --#BEGIN end if; if pl.i.exception_table then -- replace spaces with underscores pl.v.exception_table := translate(pl.v.exception_table,' ','_'); end if; if pl.i.name then -- replace spaces with underscores cihtbl.remove_spaces(pl.v.name); --B631806 end if; --#END END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id rm.reference) IS BEGIN -- Access rights for primary key constraint derive from the table -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(id,sac_type,operation,'SAC'); null; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id rm.reference, pl cioprimary_key_constraint.data) IS BEGIN if operation = 'INS' or (operation = 'UPD' and pl.i.name = true) then -- Need to do a UID check on constraints rmman.log_change('CIHPCOU1',pl.v.id); end if; if pl.i.name then -- check name is a valid ORACLE name if cihtbl.is_name_valid(pl.v.name) then ciierr.fatal(1003,ciiutl.identify(pl.v.id, pl.v.types),pl.v.name); end if; end if; if operation = 'INS' then cihpco.create_cnus(pl.v.id, pl.v.table_reference); end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id rm.reference) IS BEGIN if operation = 'DEL' then -- Delete the constraint and all it's related sub-bits ciiutl.delete_element(id,sac_type); end if; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id rm.reference) IS dummy number; error_count number := 0; BEGIN null; END; --================================== ONLY_ONE ===============================-- -- Returns false if a primary constraint exists for this table FUNCTION only_one(table_ref rm.reference) RETURN boolean IS cnt number; BEGIN select count(*) into cnt from ci_primary_key_constraints pc where pc.table_reference = only_one.table_ref ; if cnt > 1 then return(false); else return(true); end if; END; --============================================================================== --Returns true if the column referenced by col_ref is in a primary key constraint --B614703 FUNCTION column_in_primary_key(col_ref rm.reference) RETURN boolean IS cursor col_cur is select constraint_type from ci_key_components where column_reference = col_ref and constraint_type = 'PRIMARY'; col_rec col_cur%ROWTYPE; BEGIN open col_cur; fetch col_cur into col_rec; if col_cur%FOUND then close col_cur; return(true); else close col_cur; return(false); end if; END; --========================= IS COLUMN UPDATEABLE ============================-- FUNCTION is_column_updateable(column_id number) RETURN boolean IS cnt number; BEGIN select count(*) into cnt from ci_primary_key_constraints pco, ci_key_components oky where oky.column_reference = is_column_updateable.column_id and oky.constraint_reference = pco.id and pco.key_updateable = 'N'; if cnt = 0 then return(true); else return(false); end if; END; --========================= CREATE CNUS =====================================-- PROCEDURE create_cnus(oco_id number, oco_tab_id number) IS -- save_csynch boolean; -- cnupl cioconstraint_usage.data; -- -- cursor get_mti (oco_tab_ref number) is -- select mti.id -- from ci_module_detail_table_usages mti -- ,ci_app_sys_tables apptbl -- where apptbl.table_reference = mti.table_reference -- and apptbl.application_system_reference = cdapi.app_sys_ref -- and mti.table_reference = oco_tab_ref; BEGIN null; -- Removed due to bug 982297 -- if cdapi.load_mode then return; end if; -- -- for mti in get_mti(oco_tab_id) loop -- cnupl.v.table_usage_reference := mti.id; -- cnupl.i.table_usage_reference := true; -- cnupl.v.constraint_reference := oco_id; -- cnupl.i.constraint_reference := true; -- cnupl.i.ivid := false; -- begin -- save_csynch := rm.do_csynch; -- rm.do_csynch := true; -- cioconstraint_usage.ins(null, cnupl); -- rm.do_csynch := save_csynch; -- exception -- In case ins call fails, must not be left in system mode -- when others then -- rm.do_csynch := save_csynch; -- raise; -- end; -- end loop; END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /