------------------------------------------------ -- Package: JR_ERROR -- Author : Will Stallard -- Date : 21st Sept 1999 -- -- This package contains methods used by the -- repository packages for posting specific -- errors to the RMMES error stack. The package -- handles getting hold of parameters such as -- element paths and nls names for element types ------------------------------------------------ prompt Package Body: jr_error create or replace package body jr_error is ---------------------------------------------- -- Private method declarations ---------------------------------------------- function get_nls_type(type_id in number) return varchar2; function get_nls_type(type_id in number) return varchar2 is type_name rm_element_type_extensions.nls_name%type; begin select etx.nls_name into type_name from rm_element_type_extensions etx where etx.for_type=type_id; return type_name; exception when NO_DATA_FOUND then return NULL; end; ---------------------------------------------- -- jr_error.POST_REF_ERROR() -- -- Posts errors raised by referential integrity -- violations - either a blocking FK reference, -- or attempt to update a PK which has FK -- references. ----------------------------------------------- procedure post_ref_error(parent_ivid in number ,parent_type in number ,child_irid in number ,child_type in number ,action in varchar2) is par_type_name rm_element_type_extensions.nls_name%type; chld_type_name rm_element_type_extensions.nls_name%type; begin par_type_name := get_nls_type(parent_type); chld_type_name := get_nls_type(child_type); if action='DEL' then --Delete error --Nasty hack: by the time we get here, the object is already in the --wastebasket, so we take it out again temporarily, so the name service --can see it. update I$SDD_OBJECT_VERSIONS set wastebasket = 'N' where ivid=parent_ivid; -- Post the error -- %0!s %1!s is referenced by %2!s %3!s. -- Example : Domain DOM1 is referenced by Attribute ATT1 rmmes.post('CDR',2001,par_type_name ,jr_name.get_path(parent_ivid,parent_type,'NAME') ,chld_type_name ,jr_name.get_path(child_irid,child_type,'NAME')); update I$SDD_OBJECT_VERSIONS set wastebasket = 'Y' where ivid=parent_ivid; elsif action = 'UPD' then -- Update error -- Post the error -- %0!s %1!s is referenced by %2!s %3!s. -- Example : Domain DOM1 is referenced by Attribute ATT1 -- This message differs from the one above in that the cause and action -- mention update rather than delete rmmes.post('CDR',1051,par_type_name ,jr_name.get_path(parent_ivid,parent_type,'NAME') ,chld_type_name ,jr_name.get_path(child_irid,child_type,'NAME')); end if; end post_ref_error; ---------------------------------------------- -- jr_error.POST_REFERENCING_ERROR() -- -- Posts errors raised by referential integrity -- violations - when a FK reference is invalid -- Errors: CDR-1052 ----------------------------------------------- procedure post_referencing_error ( object_ivid in number , object_type in number , fkref in number , ref_type in number , action in varchar2 ) is object_type_name rm_element_type_extensions.nls_name%type; ref_type_name rm_element_type_extensions.nls_name%type; begin object_type_name := get_nls_type(object_type); ref_type_name := get_nls_type(ref_type); if action = 'INS' or action = 'UPD' then -- Post the error -- %0!s %1!s is referencing invalid %2!s (ref = %3!s). -- Example : Attribute ATT1 is referencing invalid Domain (ref = 1234). rmmes.post('CDR',1052,object_type_name ,jr_name.get_path(object_ivid,object_type,'NAME') ,ref_type_name ,fkref); end if; end post_referencing_error; ---------------------------------------------- -- jr_error.POST_UPD_CHECKIN_ERROR() -- -- Posts error raised by attempt to update a -- checked in object. -- Error: CDR-2622 ----------------------------------------------- procedure post_upd_checkin_error(ivid in number) is nls_type_name rm_element_type_extensions.nls_name%TYPE; obj_name i$sdd_object_versions.name%TYPE; begin --Get the type name select etx.nls_name into nls_type_name from RM_ELEMENT_TYPE_EXTENSIONS etx ,I$SDD_OBJECT_VERSIONS ov where etx.for_type=ov.logical_type_id and ov.ivid=post_upd_checkin_error.ivid; -- Post the error --B1306725 Need to post a specific error message if we are deleting the --last remaining (root) version of an object and it is referenced by --checked in objects. This is a _REALLY_ hacky way of detecting this --condition, but it works... --TODO:We really need a specific flag to indicate this, and pick it up here! if (jr_context.workarea is null and jr_wastebasket.saved_wa_context is not null) then --Workarea has been nulled so that secondary updates are applied --across entire repository context (see bug 972193) --Removal of root version is blocked as object referenced by checked in %1!s %0!s rmmes.post('CDR',2023,jr_name.get_path(ivid,'VLABEL') ,nls_type_name); else -- Normal condition is simply attempt to update a checked in object! -- Cannot update checked in %0!s: %1!s rmmes.post('CDR',2622,nls_type_name,jr_name.get_path(ivid,'NAME')); end if; exception when OTHERS then --ORA-04091 table is mutating, trigger/function may not see it if SQLCODE=-4091 then --This is a nasty hack to fix bug 1250493. We may get a mutating --table error, if the element being updated was a container --(JR_NAME.GET_PATH queries SDD_FOLDERS). So, instead of posting full path, --we just post the folder name. select obj.name into obj_name from I$SDD_OBJECT_VERSIONS obj where obj.ivid=post_upd_checkin_error.ivid; rmmes.post('CDR',2622,nls_type_name,obj_name); end if; end post_upd_checkin_error; ---------------------------------------------- -- jr_error.POST_DEL_ERROR() -- -- Posts error raised by failure to delete/purge -- an element -- Error: CDR-2000 ----------------------------------------------- procedure post_del_error(ivid in number ,el_type in number) is nls_type_name rm_element_type_extensions.nls_name%TYPE; begin nls_type_name:=get_nls_type(el_type); --Nasty hack: by the time we get here, the object is already in the --wastebasket, so we take it out again temporarily, so the name service --can see it. update I$SDD_OBJECT_VERSIONS ov set wastebasket = 'N' where ov.ivid=post_del_error.ivid; --Post the error --Cannot delete %0!s %1!s rmmes.post('CDR',2000,nls_type_name,jr_name.get_path(ivid,el_type,'NAME')); --Put object back in wastebasket! update I$SDD_OBJECT_VERSIONS ov set wastebasket = 'Y' where ov.ivid=post_del_error.ivid; end post_del_error; ---------------------------------------------- -- jr_error.POST_DEL_ERROR() -- -- Posts error raised by attempt to delete -- a secondary element where the primary -- element is checked in -- Error: CDR-2003 ----------------------------------------------- procedure post_del_ci_sac_error(sac_ivid in number ,sac_type_id in number ,pac_ivid in number) is sac_type_name varchar2(240); pac_type_name varchar2(240); pac_type_id number; begin --Get hold of the primary element type select ov.logical_type_id into pac_type_id from I$SDD_OBJECT_VERSIONS ov where ov.ivid=pac_ivid; pac_type_name:=get_nls_type(pac_type_id); sac_type_name:=get_nls_type(sac_type_id); --Post the error --B1306725 Need to post a specific error message if we are deleting the --last remaining (root) version of an object an it is referenced by --checked in objects. This is a _REALLY_ hacky way of detecting this --condition, but it works... --TODO:We really need a specific flag to indicate this, and pick it up here! if (jr_context.workarea is null and jr_wastebasket.saved_wa_context is not null) then --Workarea has been nulled so that secondary deletes/updates are applied --across entire repository context (see bug 972193) --Removal of root version is blocked as object referenced by checked in %1!s %0!s rmmes.post('CDR',2023,jr_name.get_path(sac_ivid,sac_type_id,'VLABEL') ,sac_type_name); else --Normally posting error because of simple delete of SAC from a checked in PAC --Cannot delete %1!s %0!s as owning %2!s %3!s is checked in rmmes.post('CDR',2003,jr_name.get_path(sac_ivid,sac_type_id,'NAME') ,sac_type_name ,pac_type_name ,jr_name.get_path(pac_ivid,'NAME')); end if; end post_del_ci_sac_error; end jr_error; /