rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\CIVWTAB.HPB 1.2 1998/12/30 15:02:49 loldham Exp $ rem Rem Copyright (c) 1994 by Oracle Corporation Rem NAME Rem civwtab.hpb - Rem DESCRIPTION Rem Rem RETURNS Rem Rem NOTES Rem Rem MODIFIED (MM/DD/YY) Rem jwetherb 10/12/94 - Add unique_complex_snp() function Rem jwetherb 09/29/94 - Creation REM *************************************************************************** REM Hand-carved package body for RELATION SELECTION created on 29-SEP-94 REM *************************************************************************** CREATE OR REPLACE PACKAGE BODY cihvwtab IS -- Generic post-process routines PROCEDURE check_delete(id number); str_type constant varchar2(6) := 'VWTAB'; part_type constant varchar2(6) := 'TAB'; use_type constant varchar2(6) := 'TAB'; --======================== PRE-PROCESS (INS,UPD) ============================-- PROCEDURE pre_process(operation varchar2,id number, pl in out NOCOPY ciorelation_selection.data) IS cnt number; BEGIN -- Perform INSERT-specific processing if operation = 'INS' then -- Check for existence of view and table -- elements if ciiutl.el_exists(pl.v.view_reference,part_type) = false then ciierr.fatal(3500,'RELATION SELECTION','view', pl.v.view_reference); end if; if ciiutl.el_exists(pl.v.table_reference,use_type) = false then ciierr.fatal(3500,'RELATION SELECTION','table', pl.v.table_reference); end if ; else if ciiutl.el_exists(id,str_type) = false then ciierr.fatal(3504,ciiutl.nls_type_name('RELATION_SELECTION'),id); end if; end if; -- Access rights for relation selection derive from the view -- Access rights checking performed by triggers in config 4.0.9 -- ciiacc.check_access_rights(pl.v.view_reference, -- part_type,'UPD','SHR'); -- if operation = 'INS' then -- ciiacc.check_access_rights(pl.v.table_reference, use_type,'SEL','SHR'); -- end if; -- Validate user-defined properties if cieval.is_extended then cieval.check_association(id,pl.v.types,(operation='UPD') ,pl.v.view_reference ,pl.v.table_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; -- Check that relation selection with this view and -- table doesn't already exist on insert if operation = 'INS' or pl.i.sequence_number then if pl.i.sequence_number = false then pl.v.sequence_number := ciiexp.default_str_seq(pl.v.view_reference, pl.v.table_reference, str_type, NULL, 'TABLE_REF'); pl.i.sequence_number := true; end if; select count(id) into cnt from ci_relation_selections where sequence_number = pl.v.sequence_number and table_reference = pl.v.table_reference and view_reference = pl.v.view_reference; if cnt != 0 then ciierr.fatal(3501,'RELATION SELECTION',pl.v.id, ciiutl.identify(pl.v.view_reference, 'VW'), ciiutl.identify(pl.v.table_reference, 'TBL')); end if; end if; if operation = 'INS' then -- Initialize unassigned properties with default values on INSERT pl.v.element_type_name := str_type; pl.i.element_type_name := true; end if; END; --======================== PRE-PROCESS (DEL,SEL) ============================-- PROCEDURE pre_process(operation varchar2,id number) IS BEGIN -- Access rights for relation selection derive from the view -- Access rights checking performed by triggers in config 4.0.9 -- if operation = 'DEL' then -- ciiacc.check_access_rights(id,str_type,'UPD','MM'); -- else -- ciiacc.check_access_rights(id,str_type,operation,'MM'); -- end if; -- if operation is 'DELETE', make sure no non-cascading references exist if operation = 'DEL' then check_delete(id); --#BEGIN -- Set the BASE_COLUMN_REFERENCE to null for columns in the snapshot or -- view identified by VIEW_REFERENCE, where the base_column was in the -- table associated by TABLE_REFERENCE should be updated to null declare col ciocolumn.data; coli ciocolumn.rm_indicators; begin for view_column in (select vwcol.id from ci_columns vwcol,ci_columns tabcol, ci_relation_selections vwtab where vwtab.id = pre_process.id and vwcol.table_reference = vwtab.view_reference and tabcol.table_reference = vwtab.table_reference and vwcol.base_column_reference = tabcol.id) loop col.i := coli; col.v.base_column_reference := null; col.i.base_column_reference := true; ciocolumn.upd(view_column.id,col); end loop; end; --#END end if; END; --===================== POST-PROCESS (INS,UPD,SEL) ==========================-- PROCEDURE post_process(operation varchar2,id number, pl ciorelation_selection.data) IS dummy number; BEGIN -- See also cisni.hpb if operation = 'INS' then select count(*) into dummy from ci_snapshot_implementations sni ,ci_snapshot_definitions snp where (sni.snapshot_definition_reference = pl.v.view_reference and sni.refresh_type = 'FAST') or (snp.id = pl.v.view_reference and snp.updatable_flag = 'Y'); if dummy > 0 then -- snapshot is Simple select count(*) into dummy from ci_relation_selections vwtab where vwtab.view_reference = pl.v.view_reference and vwtab.id != pl.v.id; if dummy > 0 then -- %0!s: %0!s: Snapshot is Simple and %1!s is based on more than one Tab ciierr.fatal(1375, ciiutl.identify(id, pl.v.types), ciiutl.identify(pl.v.view_reference, 'VW')); end if; select count(*) into dummy from ci_relation_definitions tab where tab.id = pl.v.table_reference and tab.table_type != 'TABLE'; if dummy > 0 then -- %0!s: %0!s: Snapshot is Simple and %1!s is not based on a Table. ciierr.fatal(1376, ciiutl.identify(id, pl.v.types), ciiutl.identify(pl.v.view_reference, 'VW')); end if; end if; end if; END; --========================= POST PROCESS (DEL) ==============================-- PROCEDURE post_process(operation varchar2,id number) IS BEGIN null; END; --============================= CHECK DELETE ================================-- PROCEDURE check_delete(id number) IS dummy number; error_count number := 0; BEGIN null; END; --#BEGIN --============================= CHECK DELETE ================================-- FUNCTION unique_complex_snp(vw_ref number) RETURN boolean IS dummy number; BEGIN select count(*) into dummy from ci_relation_selections vwtab,ci_snapshot_definitions snp where snp.id = vw_ref and vwtab.view_reference = vw_ref; /* Line below removed from where clause for 2.0.1 as refresh_type moved, but was it ver correct? COMPLEX is not a valid value! and snp.refresh_type = 'COMPLEX'; */ if dummy > 1 then return(false); else return(true); end if; END; --#END --================================== END ====================================-- -- -- Package instantiation block -- BEGIN is_installed := true; END; /