rem rem Patched file for use of GUIDs - Alan Fackerell 16-Dec-1998 rem rem rm.idgen function modified to call jr_util.get_new_irid rem rather than use sdd_irid_seq.nextval rem rem $Header: \\ukst76\rcsroot.7_0\model\repman40\api\RCS\rm.rpb 1.3 1998/11/25 16:15:25 cvanes Exp $ rem Rem Copyright (c) 1993 by Oracle Corporation Rem NAME Rem rmc.sql - RM Support Package ( Body ) Rem DESCRIPTION Rem The RM support package provides a set of PL/SQL definitions for use Rem by any PL/SQL code (primarily Repository code ie procedures, Rem packages ) that has access to the RM package. rem PUBLIC FUNCTION(S) rem init - RM support: INITialise server-side repository manager rem idgen - RM support: ID GENerator rem count_nulls - RM support: COUNT number of NULLs passed rem get_idoffset - RM support: GET ID OFFSET into rm.id_offset global rem PUBLIC GLOBAL(S) rem do_preop - 'Do pre operation hook' flag rem do_postop - 'Do post operation hook' flag Rem MODIFIED (MM/DD/YY) Rem dcaruana 04/06/94 - Add function idgen Rem dcaruana 03/09/94 - Remove accessible_tables search Rem dcaruana 12/13/93 - Workaround for subtype problem in 7.1 Rem bferris 11/16/93 - Relocatable code changes Rem bferris 08/26/93 - Move do_opval to public global Rem bferris 08/26/93 - Moved preop/postop to rmu Rem bferris 08/25/93 - Preop and Postop Rem dcaruana 06/17/93 - Add count_nulls Rem jhyde 05/26/93 - sequence rm_idgenerator no longer created here Rem qttran 04/04/93 - add a SEQUENCE for activity label Rem dcaruana 01/21/93 - Created (from part of rm1/rm.sql) Rem dcaruana 01/21/93 - rnew'd create or replace package body rm as -- -- Private procedure prototypes -- -- -- Public procedures -- /* ^L */ /*-------------------------------- init ------------------------------------*/ /* NAME init - RM support: INITialise server-side repository manager MODULE DESCRIPTION This procedure initialises the server-side Repository Manager. If this procedure is called (it doesn't have to be), it should be called *before* any other repository procedures are invoked. The doopval parameter, if 'Y', indicates that constraint enforcement should be performed after each high level operation request completes. If 'N', constraint enforcement will be performed in the normal manner. This parameter defaults to 'N'. The docsynch parameter, if 'Y', indicates that the repository should synchronise all secondary updates with a client-side cache. If 'N' is specified, no synchronisation will be performed. This parameter defaults to 'N'. NOTES EXCEPTIONS RETURNS */ PROCEDURE init( doopval IN rm.yesno default 'N', docsynch IN rm.yesno default 'N') is begin do_opval := doopval='Y'; do_csynch := docsynch='Y'; -- Set do_postop based on do_opval -- do_postop := do_opval; end init; /* ^L */ /*-------------------------------- idgen -----------------------------------*/ /* NAME idgen - RM support: ID GENerator MODULE DESCRIPTION This procedure returns a new *distinct* element ID for use when creating new elements. This ID is guarenteed to be distinct across all elements and will *never* be reused by another element. The id parameter will be updated to contain the new element ID. NOTES EXCEPTIONS RETURNS */ FUNCTION idgen RETURN rm.reference IS id rm.reference; begin -- select sdd_irid_seq.nextval into id from sys.dual; -- changed for use of GUID afackere (16-dec-1998) id := jr_util.get_new_irid ; return id; end idgen; /* ^L */ /*-------------------------------- count_nulls -----------------------------*/ /* NAME count_nulls - RM support: COUNT number of NULLs passed MODULE DESCRIPTION This procedure counts and returns the number of NULL parameters passed to it (up to 10 parameters). NOTES EXCEPTIONS RETURNS */ FUNCTION count_nulls(p1 IN varchar2 default 'x', p2 IN varchar2 default 'x', p3 IN varchar2 default 'x', p4 IN varchar2 default 'x', p5 IN varchar2 default 'x', p6 IN varchar2 default 'x', p7 IN varchar2 default 'x', p8 IN varchar2 default 'x', p9 IN varchar2 default 'x', p10 IN varchar2 default 'x', p11 IN varchar2 default 'x', p12 IN varchar2 default 'x', p13 IN varchar2 default 'x', p14 IN varchar2 default 'x', p15 IN varchar2 default 'x', p16 IN varchar2 default 'x', p17 IN varchar2 default 'x', p18 IN varchar2 default 'x', p19 IN varchar2 default 'x', p20 IN varchar2 default 'x') return number is ccount number; begin ccount := 0; if p1 is null then ccount := ccount+1; end if; if p2 is null then ccount := ccount+1; end if; if p3 is null then ccount := ccount+1; end if; if p4 is null then ccount := ccount+1; end if; if p5 is null then ccount := ccount+1; end if; if p6 is null then ccount := ccount+1; end if; if p7 is null then ccount := ccount+1; end if; if p8 is null then ccount := ccount+1; end if; if p9 is null then ccount := ccount+1; end if; if p10 is null then ccount := ccount+1; end if; if p11 is null then ccount := ccount+1; end if; if p12 is null then ccount := ccount+1; end if; if p13 is null then ccount := ccount+1; end if; if p14 is null then ccount := ccount+1; end if; if p15 is null then ccount := ccount+1; end if; if p16 is null then ccount := ccount+1; end if; if p17 is null then ccount := ccount+1; end if; if p18 is null then ccount := ccount+1; end if; if p19 is null then ccount := ccount+1; end if; if p20 is null then ccount := ccount+1; end if; return ccount; end count_nulls; /* ^L */ /*-------------------------------- get_idoffset ----------------------------*/ /* NAME get_idoffset - GET ID OFFSET into rm.id_offset global MODULE DESCRIPTION This procedure loads up the 'current' repository instance's ID offset base and places it in the rm.id_offset global. This global is used by the generated code to relocate IDs at runtime. NOTES EXCEPTIONS RETURNS */ PROCEDURE get_idoffset is this_owner_name varchar2(30); begin -- Get the instance owner's dbms user name -- select owner into this_owner_name -- from accessible_tables -- where table_name = 'RM$1'; -- Get the ID offset select max(id_offset) into rm.id_offset from rm_repositories where owner_name = this_owner_name; if rm.id_offset is null then rm.id_offset := 0; end if; end get_idoffset; -- -- Private procedures -- -- -- Package instantiation time -- begin rm.get_idoffset; -- Get the ID offset into our global end rm; /