Added support for 'friendly' database constraint messages.

Changed SUPP role type description following training session.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3628 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2008-02-19 11:30:44 +00:00
parent 601cb0b8a9
commit 2b3d0c909c
5 changed files with 272 additions and 1 deletions

View File

@@ -52,6 +52,8 @@ sqlldr %1 control=adit
sqlldr %1 control=dost
sqlldr %1 control=comsg
sqlplus %1 @enable_constraints

186
Data/Seed/comsg.ctl Normal file
View File

@@ -0,0 +1,186 @@
LOAD DATA
INFILE *
INTO TABLE constraint_messages
REPLACE
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
(
constraint_name
,msg
)
BEGINDATA
ADDR_PK|Attempting to create a duplicate Addresses entry
ADIT_PK|Attempting to create a duplicate Additional_Items entry
ALTY_PK|Attempting to create a duplicate Asset_Location_Types entry
AUTH_PK|Attempting to create a duplicate Apex_Authorization entry
AUTH_RT_FK|Application Error: Attempting to violate foreign key constraint AUTH_RT_FK. Please report
BAS_DRWG_FK|Application Error: Attempting to violate foreign key constraint BAS_DRWG_FK. Please repo
BAS_PK|Attempting to create a duplicate Bases entry
BUILDING_OR_SUBBUILDING_REQ|Application Error: Attempting to violate check constraint BUILDING_OR_SU
BYRE_PK|Attempting to create a duplicate Bypass_Reasons entry
CACA_PK|Attempting to create a duplicate Care_Categories entry
CATE_ENTY_FK|Application Error: Attempting to violate foreign key constraint CATE_ENTY_FK. Please re
CATE_METY_FK|Application Error: Attempting to violate foreign key constraint CATE_METY_FK. Please re
CATE_PK|Attempting to create a duplicate Caveat_Texts entry
CATE_SVCPT_FK|Application Error: Attempting to violate foreign key constraint CATE_SVCPT_FK. Please
CNOR_PK|Attempting to create a duplicate Connection_Orientations entry
CNTY_PK|Attempting to create a duplicate Connection_Types entry
COME_COMT_FK|Application Error: Attempting to violate foreign key constraint COME_COMT_FK. Please re
COME_PK|Attempting to create a duplicate Contact_Mechanisms entry
COMSG_PK|Attempting to create a duplicate Constraint_Messages entry
COMT_PK|Attempting to create a duplicate Contact_Mechanism_Types entry
COST_ADIT_FK|Application Error: Attempting to violate foreign key constraint COST_ADIT_FK. Please re
COST_BAS_FK|Application Error: Attempting to violate foreign key constraint COST_BAS_FK. Please repo
COST_ENTY_FK|Application Error: Attempting to violate foreign key constraint COST_ENTY_FK. Please re
COST_HOU_FK|Application Error: Attempting to violate foreign key constraint COST_HOU_FK. Please repo
COST_MESC_FK|Application Error: Attempting to violate foreign key constraint COST_MESC_FK. Please re
COST_METR_FK|Application Error: Attempting to violate foreign key constraint COST_METR_FK. Please re
COST_METY_FK|Application Error: Attempting to violate foreign key constraint COST_METY_FK. Please re
COST_MODU_FK|Application Error: Attempting to violate foreign key constraint COST_MODU_FK. Please re
COST_PK|Attempting to create a duplicate Costs entry
COST_REGI_FK|Application Error: Attempting to violate foreign key constraint COST_REGI_FK. Please re
COST_SVCPT_FK|Application Error: Attempting to violate foreign key constraint COST_SVCPT_FK. Please
DIR_ENTY_FK|Application Error: Attempting to violate foreign key constraint DIR_ENTY_FK. Please repo
DIR_PK|Attempting to create a duplicate Data_Item_Roles entry
DOCU_PK|Attempting to create a duplicate Documents entry
DOEV_DOCU_FK|Application Error: Attempting to violate foreign key constraint DOEV_DOCU_FK. Please re
DOEV_DOST_FK|Application Error: Attempting to violate foreign key constraint DOEV_DOST_FK. Please re
DOEV_PK|Attempting to create a duplicate Document_Events entry
DORO_CK|Application Error: Attempting to violate check constraint DORO_CK. Please report this error
DORO_DOCU_FK|Application Error: Attempting to violate foreign key constraint DORO_DOCU_FK. Please re
DORO_DORO_UK|Attempting to enter a duplicate value (defined by unique constraintDORO_DORO_UK).
DORO_DRWG_FK|Application Error: Attempting to violate foreign key constraint DORO_DRWG_FK. Please re
DORO_ENQU_FK|Application Error: Attempting to violate foreign key constraint DORO_ENQU_FK. Please re
DORO_PK|Attempting to create a duplicate Document_Roles entry
DORO_QUTE_FK|Application Error: Attempting to violate foreign key constraint DORO_QUTE_FK. Please re
DORO_RT_FK|Application Error: Attempting to violate foreign key constraint DORO_RT_FK. Please report
DOST_PK|Attempting to create a duplicate Document_Status_Types entry
DRWG_PK|Attempting to create a duplicate Drawings entry
ENEV_ENQU_FK|Application Error: Attempting to violate foreign key constraint ENEV_ENQU_FK. Please re
ENEV_ENST_FK|Application Error: Attempting to violate foreign key constraint ENEV_ENST_FK. Please re
ENEV_PK|Attempting to create a duplicate Enquiry_Events entry
ENQU_ALTY_FK|Application Error: Attempting to violate foreign key constraint ENQU_ALTY_FK. Please re
ENQU_CACA_FK|Application Error: Attempting to violate foreign key constraint ENQU_CACA_FK. Please re
ENQU_COMT_AGENT_FK|Application Error: Attempting to violate foreign key constraint ENQU_COMT_AGENT_F
ENQU_ENTY_FK|Application Error: Attempting to violate foreign key constraint ENQU_ENTY_FK. Please re
QUIT_MODU_FK|Application Error: Attempting to violate foreign key constraint QUIT_MODU_FK. Please re
QUIT_PK|Attempting to create a duplicate Quote_Items entry
QUIT_QUTE_FK|Application Error: Attempting to violate foreign key constraint QUIT_QUTE_FK. Please re
QUIT_SVCPT_FK|Application Error: Attempting to violate foreign key constraint QUIT_SVCPT_FK. Please
QURE_ENQU_FK|Application Error: Attempting to violate foreign key constraint QURE_ENQU_FK. Please re
QURE_PK|Attempting to create a duplicate Quote_Reasoning entry
QURO_PK|Attempting to create a duplicate Quote_Roles entry
QURO_PRTY_FK|Application Error: Attempting to violate foreign key constraint QURO_PRTY_FK. Please re
QURO_QUTE_FK|Application Error: Attempting to violate foreign key constraint QURO_QUTE_FK. Please re
QURO_RT_FK|Application Error: Attempting to violate foreign key constraint QURO_RT_FK. Please report
QUST_PK|Attempting to create a duplicate Quote_Statuses entry
QUTE_ENQU_FK|Application Error: Attempting to violate foreign key constraint QUTE_ENQU_FK. Please re
QUTE_PK|Attempting to create a duplicate Quotes entry
REEX_ADIT_FK|Application Error: Attempting to violate foreign key constraint REEX_ADIT_FK. Please re
REEX_ENTY_FK|Application Error: Attempting to violate foreign key constraint REEX_ENTY_FK. Please re
REEX_PK|Attempting to create a duplicate Regi_Enqu_Exclusions entry
REEX_REEX_UK|Attempting to enter a duplicate value (defined by unique constraintREEX_REEX_UK).
REEX_REGI_FK|Application Error: Attempting to violate foreign key constraint REEX_REGI_FK. Please re
REGI_PK|Attempting to create a duplicate Regions entry
REGU_PK|Attempting to create a duplicate Regulators entry
REGU_RETY_FK|Application Error: Attempting to violate foreign key constraint REGU_RETY_FK. Please re
RETY_PK|Attempting to create a duplicate Regulator_Types entry
REVA_PK|Attempting to create a duplicate Relief_Valves entry
REVA_RVTY_FK|Application Error: Attempting to violate foreign key constraint REVA_RVTY_FK. Please re
RT_PK|Attempting to create a duplicate Role_Types entry
RVTY_PK|Attempting to create a duplicate Relief_Valve_Types entry
SLTY_PK|Attempting to create a duplicate Slamshut_Types entry
SLVA_PK|Attempting to create a duplicate Slamshut_Valves entry
SLVA_SLTY_FK|Application Error: Attempting to violate foreign key constraint SLVA_SLTY_FK. Please re
SVCPT_PK|Attempting to create a duplicate Service_Pressure_Types entry
SVCP_PK|Attempting to create a duplicate Service_Pressures entry
SVCP_SVCPT_FK|Application Error: Attempting to violate foreign key constraint SVCP_SVCPT_FK. Please
SYCO_PK|Attempting to create a duplicate System_Configuration entry
PREL_PARL_FROM_FK|Application Error: Attempting to violate foreign key constraint PREL_PARL_FROM_FK.
PREL_PARL_TO_FK|Application Error: Attempting to violate foreign key constraint PREL_PARL_TO_FK. Ple
PREL_PK|Attempting to create a duplicate Party_Relationships entry
PREL_PRTP_FK|Application Error: Attempting to violate foreign key constraint PREL_PRTP_FK. Please re
PRTP_PK|Attempting to create a duplicate Party_Relationship_Types entry
PRTP_RT_FK|Application Error: Attempting to violate foreign key constraint PRTP_RT_FK. Please report
PRTP_RT_FROM_FK|Application Error: Attempting to violate foreign key constraint PRTP_RT_FROM_FK. Ple
PRTY_MANU_MANU_REF_UK|Attempting to enter a duplicate value (defined by unique constraintPRTY_MANU_M
PRTY_MKTP_MKTP_REF_UK|Attempting to enter a duplicate value (defined by unique constraintPRTY_MKTP_M
PRTY_PK|Attempting to create a duplicate Parties entry
PWD_PK|Attempting to create a duplicate Passwords entry
PWD_PRTY_FK|Application Error: Attempting to violate foreign key constraint PWD_PRTY_FK. Please repo
QUEV_PK|Attempting to create a duplicate Quote_Events entry
QUEV_QUST_FK|Application Error: Attempting to violate foreign key constraint QUEV_QUST_FK. Please re
QUEV_QUTE_FK|Application Error: Attempting to violate foreign key constraint QUEV_QUTE_FK. Please re
QUIT_ADIT_FK|Application Error: Attempting to violate foreign key constraint QUIT_ADIT_FK. Please re
QUIT_BAS_FK|Application Error: Attempting to violate foreign key constraint QUIT_BAS_FK. Please repo
QUIT_ENTY_FK|Application Error: Attempting to violate foreign key constraint QUIT_ENTY_FK. Please re
QUIT_HOU_FK|Application Error: Attempting to violate foreign key constraint QUIT_HOU_FK. Please repo
QUIT_MESC_FK|Application Error: Attempting to violate foreign key constraint QUIT_MESC_FK. Please re
QUIT_METY_FK|Application Error: Attempting to violate foreign key constraint QUIT_METY_FK. Please re
ENQU_MESC_EXISTING_FK|Application Error: Attempting to violate foreign key constraint ENQU_MESC_EXIS
ENQU_MESC_REQUIRED_FK|Application Error: Attempting to violate foreign key constraint ENQU_MESC_REQU
ENQU_METY_FK|Application Error: Attempting to violate foreign key constraint ENQU_METY_FK. Please re
ENQU_PK|Attempting to create a duplicate Enquiries entry
ENQU_SVCP_REQUIRED_FK|Application Error: Attempting to violate foreign key constraint ENQU_SVCP_REQU
ENRO_ENQU_FK|Application Error: Attempting to violate foreign key constraint ENRO_ENQU_FK. Please re
ENRO_PK|Attempting to create a duplicate Enquiry_Roles entry
ENRO_PRTY_FK|Application Error: Attempting to violate foreign key constraint ENRO_PRTY_FK. Please re
ENRO_RT_FK|Application Error: Attempting to violate foreign key constraint ENRO_RT_FK. Please report
ENST_PK|Attempting to create a duplicate Enquiry_Status_Types entry
ENTY_PK|Attempting to create a duplicate Enquiry_Types entry
ERLO_PK|Attempting to create a duplicate Error_Logs entry
EXME_PK|Attempting to create a duplicate Exception_Messages entry
FITY_PK|Attempting to create a duplicate Filter_Types entry
FLTR_FITY_FK|Application Error: Attempting to violate foreign key constraint FLTR_FITY_FK. Please re
FLTR_PK|Attempting to create a duplicate Filters entry
HOTY_PK|Attempting to create a duplicate Housing_Types entry
HOU_DRWG_FK|Application Error: Attempting to violate foreign key constraint HOU_DRWG_FK. Please repo
HOU_HOTY_FK|Application Error: Attempting to violate foreign key constraint HOU_HOTY_FK. Please repo
HOU_PK|Attempting to create a duplicate Housings entry
HOU_PRTY_FK|Application Error: Attempting to violate foreign key constraint HOU_PRTY_FK. Please repo
LETI_ENTY_FK|Application Error: Attempting to violate foreign key constraint LETI_ENTY_FK. Please re
LETI_MESC_FK|Application Error: Attempting to violate foreign key constraint LETI_MESC_FK. Please re
LETI_METY_FK|Application Error: Attempting to violate foreign key constraint LETI_METY_FK. Please re
LETI_PK|Attempting to create a duplicate Lead_Times entry
LETI_SVCPT_FK|Application Error: Attempting to violate foreign key constraint LETI_SVCPT_FK. Please
MESC_PK|Attempting to create a duplicate Meter_Size_Codes entry
METR_DRWG_FK|Application Error: Attempting to violate foreign key constraint METR_DRWG_FK. Please re
METR_METY_FK|Application Error: Attempting to violate foreign key constraint METR_METY_FK. Please re
METR_PK|Attempting to create a duplicate Meters entry
METR_PRTY_FK|Application Error: Attempting to violate foreign key constraint METR_PRTY_FK. Please re
METY_PK|Attempting to create a duplicate Meter_Types entry
MODU_BAS_FK|Application Error: Attempting to violate foreign key constraint MODU_BAS_FK. Please repo
MODU_CNOR_INLET_FK|Application Error: Attempting to violate foreign key constraint MODU_CNOR_INLET_F
MODU_CNOR_OUTLET_FK|Application Error: Attempting to violate foreign key constraint MODU_CNOR_OUTLET
MODU_CNTY_INLET_FK|Application Error: Attempting to violate foreign key constraint MODU_CNTY_INLET_F
MODU_CNTY_OUTLET_FK|Application Error: Attempting to violate foreign key constraint MODU_CNTY_OUTLET
MODU_DRWG_FK|Application Error: Attempting to violate foreign key constraint MODU_DRWG_FK. Please re
MODU_FLTR_FK|Application Error: Attempting to violate foreign key constraint MODU_FLTR_FK. Please re
MODU_HOU_FK|Application Error: Attempting to violate foreign key constraint MODU_HOU_FK. Please repo
MODU_METR_FK|Application Error: Attempting to violate foreign key constraint MODU_METR_FK. Please re
MODU_PK|Attempting to create a duplicate Modules entry
MODU_PRTY_FK|Application Error: Attempting to violate foreign key constraint MODU_PRTY_FK. Please re
MODU_REGU_FK|Application Error: Attempting to violate foreign key constraint MODU_REGU_FK. Please re
MODU_REVA_FK|Application Error: Attempting to violate foreign key constraint MODU_REVA_FK. Please re
MODU_SLVA_FK|Application Error: Attempting to violate foreign key constraint MODU_SLVA_FK. Please re
MODU_SVCP_FK|Application Error: Attempting to violate foreign key constraint MODU_SVCP_FK. Please re
PADDR_ADDR_FK|Application Error: Attempting to violate foreign key constraint PADDR_ADDR_FK. Please
PADDR_PK|Attempting to create a duplicate Party_Addresses entry
PADDR_PRTY_FK|Application Error: Attempting to violate foreign key constraint PADDR_PRTY_FK. Please
PARL_PK|Attempting to create a duplicate Party_Roles entry
PARL_PRTP_MISMATCH|Application Error: Attempting to violate check constraint PARL_PRTP_MISMATCH. Ple
PARL_PRTY_FK|Application Error: Attempting to violate foreign key constraint PARL_PRTY_FK. Please re
PARL_RT_FK|Application Error: Attempting to violate foreign key constraint PARL_RT_FK. Please report
PAR_PADDR_FK|Application Error: Attempting to violate foreign key constraint PAR_PADDR_FK. Please re
PAR_PK|Attempting to create a duplicate Party_Address_Roles entry
PAR_RT_FK|Application Error: Attempting to violate foreign key constraint PAR_RT_FK. Please report t
PCMR_PCM_FK|Application Error: Attempting to violate foreign key constraint PCMR_PCM_FK. Please repo
PCMR_PK|Attempting to create a duplicate Party_Contact_Mechanism_Roles entry
PCMR_RT_FK|Application Error: Attempting to violate foreign key constraint PCMR_RT_FK. Please report
PCM_COME_FK|Application Error: Attempting to violate foreign key constraint PCM_COME_FK. Please repo
PCM_PADDR_FK|Application Error: Attempting to violate foreign key constraint PCM_PADDR_FK. Please re
PCM_PK|Attempting to create a duplicate Party_Contact_Mechanisms entry
PCM_PRTY_FK|Application Error: Attempting to violate foreign key constraint PCM_PRTY_FK. Please repo
POCO_PK|Attempting to create a duplicate Postcodes entry
POCO_POCO_UK|Attempting to enter a duplicate value (defined by unique constraintPOCO_POCO_UK).
POCO_REGI_FK|Application Error: Attempting to violate foreign key constraint POCO_REGI_FK. Please re

View File

@@ -34,7 +34,7 @@ MAINHOMEFAX|Main home fax|PCMRT
SECHOMEPHONE|Secondary home number|PCMRT
SECHOMEFAX|Secondary home fax|PCMRT
AGENT|Agent|PRT
SUPP|Service supplier|PRT
SUPP|Gas supplier|PRT
SUPPADMIN|User administrator|PRT
MIPADMIN|System Administrator|PRT
ICU|Quotation operative|PRT

View File

@@ -26,5 +26,6 @@ exec gen_mandatory
@@mip_tripartite.pck
@@mip_virus_check.pck
@@mip_email.pck
@@mip_friendly_messages.pck
@@compile.sql
exit

View File

@@ -0,0 +1,82 @@
CREATE OR REPLACE PACKAGE mip_friendly_messages IS
-- Author : HARDYA
-- Created : 19/02/2008 09:45:09
-- Purpose :
/** Attempt to produce a user friendly message for an Oracle message
%param p_ora_msg the message to be processed
%return either a friendly message or p_ora_msg
*/
FUNCTION get_friendly_message(p_ora_msg IN VARCHAR2) RETURN VARCHAR2;
END mip_friendly_messages;
/
CREATE OR REPLACE PACKAGE BODY mip_friendly_messages IS
FUNCTION get_constraint_message(p_ora_msg IN VARCHAR2) RETURN VARCHAR2 IS
c_marker CONSTANT VARCHAR2(30) := 'constraint (';
c_marker_length CONSTANT NUMBER := length(c_marker);
l_msg constraint_messages.msg%TYPE;
l_constraint VARCHAR2(30);
l_constraint_name VARCHAR2(30);
l_start_posn NUMBER;
l_end_posn NUMBER;
BEGIN
-- get the complete constraint "user.constraint_name"
l_start_posn := instr(p_ora_msg
,c_marker) + c_marker_length;
l_end_posn := instr(p_ora_msg
,')'
,l_start_posn) - 1;
l_constraint := substr(p_ora_msg
,l_start_posn
,l_end_posn - l_start_posn + 1);
-- get the "constraint_name"
l_start_posn := instr(l_constraint
,'.') + 1;
l_constraint_name := substr(l_constraint
,l_start_posn);
BEGIN
SELECT msg
INTO l_msg
FROM constraint_messages
WHERE constraint_name = l_constraint_name;
EXCEPTION
WHEN no_data_found THEN
l_msg := NULL;
END;
IF l_msg IS NULL
AND l_constraint_name LIKE 'SYS!_C%' ESCAPE '!'
OR l_constraint_name LIKE 'AVCON!_%' ESCAPE '!' THEN
-- this is a system generated check constraint and should not be appearing
l_msg := 'Application error. Attempting to violate check constraint ' ||
l_constraint_name ||
'. Please report this error to Advantica.';
END IF;
RETURN l_msg;
END;
FUNCTION get_friendly_message(p_ora_msg IN VARCHAR2) RETURN VARCHAR2 IS
l_ora_msg VARCHAR2(240) := p_ora_msg;
l_sqlcode NUMBER;
l_msg VARCHAR2(2000);
BEGIN
l_sqlcode := substr(l_ora_msg
,1
,5);
IF instr(l_ora_msg
,'constraint (') > 0 THEN
l_msg := nvl(get_constraint_message(l_ora_msg)
,l_ora_msg);
ELSE
l_msg := l_ora_msg;
END IF;
htp.prn(l_msg);
END get_friendly_message;
END mip_friendly_messages;
/