1 PACKAGE BODY WSH_CC_RESPONSE_PKG AS
2 /* $Header: WSHGTRPB.pls 115.3 2002/06/03 12:31:07 pkm ship $ */
3
4 SUCCESS_ERROR CONSTANT VARCHAR2(10) := 'SUCCESS';
5 ONHOLD_ERROR CONSTANT VARCHAR2(10) := 'ON_HOLD';
6 DATA_ERROR CONSTANT VARCHAR2(10) := 'DATA';
7 SYSTEM_ERROR CONSTANT VARCHAR2(10) := 'SYSTEM';
8
9
10 -- Name
11 -- INTERPRET_ERROR
12 -- Purpose
13 -- Internal. On passing the interpreted error, it sets the result code
14 -- based on the priority of the code
15 -- Arguments
16 -- fetch_interpreted_code Interpreted code got from the rule
17 -- interpreted_code Interpreted code to be returned
18
19 PROCEDURE INTERPRET_ERROR (
20 fetch_interpreted_code IN WSH_GTC_RESPONSE_RULES.INTERPRETED_VALUE_CODE%TYPE,
21 interpreted_code IN OUT WSH_GTC_RESPONSE_RULES.INTERPRETED_VALUE_CODE%TYPE)
22 IS
23 interpreted_string VARCHAR2(30);
24 BEGIN
25 IF(fetch_interpreted_code = SYSTEM_ERROR) THEN
26 interpreted_code := SYSTEM_ERROR;
27 ELSIF(fetch_interpreted_code = DATA_ERROR) AND (interpreted_code <> SYSTEM_ERROR) THEN
28 interpreted_code := DATA_ERROR;
29 ELSIF(fetch_interpreted_code = ONHOLD_ERROR) AND (interpreted_code NOT IN (SYSTEM_ERROR, DATA_ERROR) ) THEN
30 interpreted_code := ONHOLD_ERROR;
31 END IF;
32 END;
33
34
35 -- Name
36 -- ONT_RESPONSE_ANALYSER
37 -- Purpose
38 -- On passing the transaction_control_id of a request this package returns
39 -- the interpreted status of the request based on the rules defined
40 -- Arguments
41 -- trans_control_id transaction_control_id of a request
42 -- response_header_id transaction_control_id of a request
43 -- result_status status returned as record T_RESULT_STATUS_REC
44 -- Notes
45 -- Refer the record T_RESULT_STATUS_REC
46 PROCEDURE ONT_RESPONSE_ANALYSER (
47 trans_control_id IN NUMBER,
48 response_header_id IN NUMBER,
49 result_status OUT t_result_status_rec)
50 IS
51
52 fetch_interpreted_code WSH_GTC_RESPONSE_RULES.INTERPRETED_VALUE_CODE%TYPE;
53 fetch_error_code WSH_CC_RESPONSE_LINES.ERROR_CODE%TYPE;
54 fetch_error_type WSH_CC_RESPONSE_LINES.ERROR_TYPE%TYPE;
55 response_hdr_id NUMBER;
56
57 CURSOR Get_Response_Header( trans_control_id NUMBER) IS
58 SELECT response_header_id, c.error_code, interpreted_value_code
59 FROM WSH_CC_TRANS_CONTROL c, WSH_GTC_RESPONSE_RULES r
60 WHERE transaction_control_id = trans_control_id and c.error_code = r.error_code(+) ;
61
62
63 CURSOR Get_Response_Line_Details( resp_header_id NUMBER) IS
64 SELECT l.error_code error_code, l.error_type error_type,
65 denied_party_flag, embargo_flag, license_required
66 FROM WSH_CC_RESPONSE_LINES l
67 WHERE response_header_id = resp_header_id;
68
69 CURSOR Get_Interpreted_code(p_error_code VARCHAR2, p_error_type VARCHAR2) IS
70 SELECT interpreted_value_code
71 FROM WSH_GTC_RESPONSE_RULES
72 WHERE error_type = p_error_type and nvl(error_code,p_error_code) = p_error_code
73 ORDER BY error_code;
74
75 BEGIN
76 oe_debug_pub.add('***Inside the procedure ONT_RESPONSE_ANALYSER***');
77 result_status.status_code := SUCCESS_ERROR;
78 result_status.dp_flag := 'N';
79 result_status.em_flag := 'N';
80 result_status.ld_flag := 'N';
81
82 OPEN Get_Response_Header(trans_control_id);
83
84 FETCH Get_Response_Header INTO response_hdr_id, fetch_error_code, fetch_interpreted_code;
85
86 IF Get_Response_Header%NOTFOUND THEN
87 oe_debug_pub.Add('Trans Control Id is not Found');
88 --Invalid trans control
89 result_status.status_code := SYSTEM_ERROR;
90 return;
91 END IF;
92
93 CLOSE Get_Response_Header;
94 IF (fetch_error_code is not NULL) AND (fetch_interpreted_code is NULL) THEN --Rule not found
95 oe_debug_pub.Add('Error in the Trans Control and There Is no Rule Defined');
96 fetch_interpreted_code := DATA_ERROR; --Default is DATA ERR
97 END IF;
98 IF fetch_interpreted_code is not NULL THEN
99 oe_debug_pub.Add('Interpreted Error in the Trans Control - ' || fetch_interpreted_code );
100 interpret_error(fetch_interpreted_code, result_status.status_code ) ;
101 IF(result_status.status_code = SYSTEM_ERROR) THEN
102 return;
103 END IF;
104 END IF;
105
106 FOR resp IN Get_Response_Line_Details(response_hdr_id) LOOP
107 IF ((resp.error_code is not NULL) OR (resp.error_type is not NULL)) THEN
108 OPEN Get_Interpreted_code(resp.error_code, resp.error_type);
109 FETCH Get_Interpreted_code INTO fetch_interpreted_code;
110 IF Get_Interpreted_code%NOTFOUND THEN --Rule not found
111 fetch_interpreted_code := DATA_ERROR; --Default is DATA ERR
112 oe_debug_pub.Add('Reponse Line Error, Rule Nof Found for Code ' || resp.error_code || ' Type ' || resp.error_type );
113 END IF;
114 oe_debug_pub.Add('Reponse Line Error, Interpreted Code - ' || fetch_interpreted_code );
115 interpret_error(fetch_interpreted_code, result_status.status_code ) ;
116 END IF;
117
118 IF resp.denied_party_flag = 'Y' THEN
119 oe_debug_pub.Add('Denied Party is found' );
120 result_status.dp_flag := 'Y';
121 END IF;
122 IF resp.embargo_flag = 'Y' THEN
123 oe_debug_pub.Add('Embargo is found' );
124 result_status.em_flag := 'Y';
125 END IF;
126 IF resp.license_required = 'Y' THEN
127 oe_debug_pub.Add('License Required' );
128 result_status.ld_flag := 'Y';
129 END IF;
130 IF(result_status.status_code = SYSTEM_ERROR) THEN
131 return;
132 END IF;
133 END LOOP;
134 EXCEPTION
135 WHEN OTHERS THEN
136 oe_debug_pub.Add('Unknown Exception has occoured' );
137 result_status.status_code := SYSTEM_ERROR;
138 END ONT_RESPONSE_ANALYSER;
139
140
141 END WSH_CC_RESPONSE_PKG;