rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\cirin.hpb 1.2 1998/10/12 15:14:00 cheaps Exp $ rem Rem Copyright (c) 1996 by Oracle Corporation Rem NAME Rem cirin.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem cvanes 07/10/96 - Creation REM *************************************************************************** REM Hand-carved package body for RELATION INDEX created on 29-APR-96 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihrin IS -- Generic post-process routines PROCEDURE check_delete(id number); sac_type constant varchar2(6) := 'IND'; pac_type varchar2(6); pac_reference number; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY ciorelation_index.data) IS BEGIN -- Calculate the PAC reference which determines access control rights -- pac_reference := nvl( -- pl.v.snapshot_definition_reference,pl.v.table_definition_reference); -- pac_type := ciiutl.short_type(pac_reference); -- Access rights for relation index derive from the snapshot_definition/ -- table_definition reference -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pac_reference,pac_type,'UPD'); -- 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.index_type := 'RIN'; pl.i.index_type := true; if pl.i.table_definition_reference then pl.v.relation_index_for := 'TBL'; elsif pl.i.snapshot_definition_reference then pl.v.relation_index_for := 'SNP'; end if; end if; -- replace spaces with underscores cihtbl.remove_spaces(pl.v.name); --B631806 END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- Access rights for relation index derive from the snapshot_definition/ -- table_definition reference -- 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 ciorelation_index.data) IS CURSOR oky_cursor IS select column_reference, cqa_reference, sequence_number,oky_arc1_for from ci_key_components where constraint_reference=pl.v.foreign_key_reference; indcol cioindex_entry.data; rin2_ref number; fco_ref number; BEGIN if operation = 'INS' or (operation = 'UPD' and pl.i.name = true) then -- Need to do a UID check on constraints rmman.log_change('CIHRINU1',pl.v.id); end if; if operation = 'UPD' and pl.i.name = true and not cdapi.load_mode then -- name has changed so must update denormalised name in indcol -- This assumes that indcol has no secondary processing associated -- with updating the name. update ci_index_entries set name = pl.v.name where relation_index_reference = 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; -- Handle RIN based on foreign key if operation = 'INS' or (operation = 'UPD' and pl.i.foreign_key_reference = true) then -- Check that no other RINs exist on this f.k. select min(rin2.id), min(rin2.foreign_key_reference) into rin2_ref, fco_ref from ci_relation_indexes rin1 ,ci_relation_indexes rin2 where rin1.foreign_key_reference = rin2.foreign_key_reference and rin1.id != rin2.id and rin1.id = pl.v.id; if rin2_ref is not null then ciierr.fatal(1373,ciiutl.identify(pl.v.id, pl.v.types), ciiutl.identify(rin2_ref, 'RIN'), ciiutl.identify(fco_ref, 'FCO') ); end if; /* COMMENTED OUT WHILST CONSULTING USERS AS TO IMPLICATIONS -- Secondary processing to create index entries based on f.k. components (B394845) -- If update, then delete any existing index entries if operation = 'UPD' then delete ci_index_entries indcol where indcol.relation_index_reference = pl.v.id; end if; -- Create new index entries (but not in load mode). if not cdapi.load_mode then indcol.v.relation_index_reference := pl.v.id; indcol.i.relation_index_reference := TRUE; FOR oky IN oky_cursor LOOP if oky.oky_arc1_for='CQA' then indcol.v.cqa_reference := oky.cqa_reference; indcol.i.cqa_reference := TRUE; indcol.v.column_reference := null; indcol.i.column_reference := FALSE; else indcol.v.column_reference := oky.column_reference; indcol.i.column_reference := TRUE; indcol.v.cqa_reference := null; indcol.i.cqa_reference := FALSE; end if; indcol.v.sequence_number := oky.sequence_number; indcol.i.sequence_number := TRUE; cioindex_entry.ins(null,indcol); END LOOP; end if; */ end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS BEGIN if operation = 'DEL' then -- Delete the relation index and all it's related sub-bits ciiutl.delete_element(id,sac_type); end if; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id number) IS dummy number; error_count number := 0; BEGIN null; END; --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /