rem rem $Header: L:\\\\model\\repman40\\api\\RCS\\rmu.rpb 1.1 1998/05/28 17:08:29 mfrobins Exp $ rem Rem NAME Rem rmuc.sql - RM Support Utility Package ( Body ) rem DESCRIPTION rem The RM support utility package provides RM support services rem in addition to the services provided in the RM package. rem PUBLIC FUNCTION(S) rem preop - RM support: PRE OPeration hook rem postop - RM support: POST OPeration hook rem MODIFIED (MM/DD/YY) Rem cvanes 07/21/95 - Creation Rem dcaruana 09/16/93 - Change debug level on rmdbg.print Rem bferris 08/27/93 - Change postop to do 'lower(...' Rem bferris 08/26/93 - Fix syntax errors Rem bferris 08/26/93 - Creation create or replace package body rmu as -- -- Private procedure prototypes -- /*--------------------------------- calldepth -------------------------------*/ /* calldepth - get procedure CALL depth (from anonymous block) */ FUNCTION calldepth return binary_integer; -- -- Public procedures -- /* ^L */ /*-------------------------------- preop -----------------------------------*/ /* NAME preop - RM support Utility: PRE OPeration hook MODULE DESCRIPTION This procedure is called by the operation layer *before* it executes the method layer to perform an operation. It has no current functionality. The prod parameter should contain the name of the product the element type is defined in. The etname parameter should contain the name of the element type that the operation is for. The opname parameter should contain the name of the operation. The DO_PREOP global can be checked to see if this procedure needs to be called. If it is false this procedure doesn't need to be called. If it is true, this procedure should be called by each operation layer procedure. NOTES EXCEPTIONS RETURNS */ PROCEDURE preop(prod IN varchar2, etname IN varchar2, opname IN varchar2) is begin if rmdbg.enabled then rmdbg.print('rmu.preop: Operation '||lower(prod)||lower(etname)||'.'|| lower(opname)||' starting...', 1 ); end if; if not rm.do_preop then return; end if; null; end preop; /* ^L */ /*-------------------------------- postop ----------------------------------*/ /* NAME postop - RM support Utility: POST OPeration hook MODULE DESCRIPTION This procedure is called by the operation layer *after* it executes the method layer to perform an operation. It is responsible for checking the 'DO_OPVAL' global and, if set, ensure that the operation did not exit with any outstanding non-warning violations. The prod parameter should contain the name of the product the element type is defined in. The etname parameter should contain the name of the element type that the operation is for. The opname parameter should contain the name of the operation. The DO_POSTOP global can be checked to see if this procedure needs to be called. If it is false this procedure doesn't need to be called. If it is true, this procedure should be called by each operation layer procedure. If DO_OPVAL is TRUE and the operation is the 'topmost' operation called from the anonymous block and there are outstanding non-warning violations, this procedure will raise the RM.VIOLATIONS exception. This will cause the *first* violation we can find to be posted on the error stack followed by a general 'Outstanding violations' error. NOTES EXCEPTIONS RMU.VIOLATIONS RETURNS */ PROCEDURE postop(prod IN varchar2, etname IN varchar2, opname IN varchar2) is ok yesno; warnings yesno; begin if rmdbg.enabled then rmdbg.print('rmu.postop: Operation '||lower(prod)||lower(etname)||'.'|| lower(opname)||' finished', 1); end if; if not rm.do_postop then return; end if; -- Nothing to do if do_opval isn't set if not rm.do_opval then return; end if; -- -- Make sure that there are no outstanding non-warning violations if -- this is called from a top-level operation request -- if calldepth<>2 then return; end if; rmmac.rmmacvl(null,ok,warnings); if ok<>'Y' then rmmes.clear; for v in ( select v.p0,v.p1,v.p2,v.p3,v.p4,v.p5,v.p6,v.p7,a.facility,a.code from rm_assertions a,rm_violations v where a.id = v.assertion and a.warning='N' ) loop rmmes.post(v.facility,v.code,v.p0,v.p1,v.p2,v.p3,v.p4,v.p5,v.p6,v.p7); exit; end loop; rmmes.post(violations_fac,violations_code,lower(prod), lower(etname),lower(opname)); raise violations; end if; end postop; -- -- Private procedures -- /* ^L */ /*-------------------------------- calldepth -------------------------------*/ /* NAME calldepth - get procedure CALL depth (from anonymous block) MODULE DESCRIPTION This procedure returns the pl/sql call depth from an anonymous block. Depth 1 indicates that the calling procedure was invoked directly from an anonymous block (or a procedure within the anonymous block). NOTES EXCEPTIONS RETURNS */ FUNCTION calldepth return binary_integer is stack varchar2(2000); stackl binary_integer; curline varchar2(100); curlineno binary_integer; cnewline binary_integer; nnewline binary_integer; linecount binary_integer; dcounter binary_integer; begin stack := dbms_utility.format_call_stack; stackl := length(stack); cnewline := 0; curlineno := 0; while cnewline3 then if instr(curline,'anonymous block')<>0 then exit; end if; end if; cnewline := nnewline; end loop; return (curlineno-5); end calldepth; end rmu; /