DBA Data[Home] [Help]

PACKAGE BODY: APPS.QA_CHART_HEADERS_PKG

Source


1 PACKAGE BODY qa_chart_headers_pkg AS
2 /* $Header: qachartb.pls 120.1 2006/03/20 10:51:15 bso noship $ */
3 
4     --
5     -- Tracking Bug 4939897
6     -- R12 Forms Tech Stack Upgrade - Obsolete Oracle Graphics
7     --
8 
9     PROCEDURE create_chart(
10     --
11     -- Create a new record in qa_chart_headers.  Return
12     -- the newly generated chart header ID in x_chart_id.
13     --
14     -- bso Mon Jan  9 15:19:52 PST 2006
15     --
16         p_criteria_id  NUMBER,
17         p_title        VARCHAR2,
18         p_description  VARCHAR2,
19         p_x_label      VARCHAR2,
20         p_y_label      VARCHAR2,
21         x_chart_id     OUT NOCOPY NUMBER) IS
22 
23     BEGIN
24         INSERT INTO qa_chart_headers(
25             created_by,
26             creation_date,
27             last_updated_by,
28             last_update_date,
29             last_update_login,
30             chart_id,
31             criteria_id,
32             title,
33             description,
34             x_label,
35             y_label)
36         VALUES(
37             fnd_global.user_id,
38             sysdate,
39             fnd_global.user_id,
40             sysdate,
41             fnd_global.login_id,
42             qa_chart_headers_s.nextval,
43             p_criteria_id,
44             p_title,
45             p_description,
46             p_x_label,
47             p_y_label)
48         RETURNING
49             chart_id
50         INTO
51             x_chart_id;
52 
53     END create_chart;
54 
55 
56     PROCEDURE delete_chart(p_chart_id NUMBER) IS
57     --
58     -- This procedure deletes a chart (header and detail
59     -- data points will be deleted together).
60     --
61     -- bso Mon Jan  9 15:24:20 PST 2006
62     --
63 
64         l_criteria_id NUMBER;
65         l_output_type NUMBER;
66 
67     BEGIN
68 
69         --
70         -- First delete the header, get the criteria ID FK as a
71         -- side effect.
72         --
73         DELETE
74         FROM        qa_chart_headers
75         WHERE       chart_id = p_chart_id
76         RETURNING   criteria_id
77         INTO        l_criteria_id;
78 
79         --
80         -- From the criteria_id FK, find the chart "output type".
81         -- which is just the type of chart.
82         --
83         -- Bug 5043954 Unnecessary error messages after viewing
84         -- unsaved charts.  l_criteria_id may be NULL in which
85         -- case the SELECT INTO will error out with no data found.
86         -- Adding an exception catcher here and then add ELSE in
87         -- the CASE statement below.
88         -- bso Mon Mar 20 10:40:09 PST 2006
89         --
90 
91         BEGIN
92             SELECT output_type
93             INTO   l_output_type
94             FROM   qa_criteria_headers
95             WHERE  criteria_id = l_criteria_id;
96         EXCEPTION
97             WHEN no_data_found THEN
98                 NULL;
99         END;
100 
101         --
102         -- Now determine which package to call to delete
103         -- the detail data points.
104         --
105 
106         CASE l_output_type
107 
108         WHEN qa_ss_const.output_type_histogram THEN
109             qa_chart_histogram_pkg.delete_data(p_chart_id);
110 
111         WHEN qa_ss_const.output_type_pareto THEN
112             qa_chart_pareto_pkg.delete_data(p_chart_id);
113 
114         WHEN qa_ss_const.output_type_trend THEN
115             qa_chart_trend_pkg.delete_data(p_chart_id);
116 
117         WHEN qa_ss_const.output_type_control THEN
118             qa_chart_control_pkg.delete_data(p_chart_id);
119 
120         ELSE
121             --
122             -- Bug 5043954 Unnecessary error messages after viewing
123             -- unsaved charts.  This is due to output_type being
124             -- NULL.  Perform conservative deletions on all child
125             -- data tables since user hasn't saved the criteria
126             -- header and we don't know what chart type it is.
127             -- Very rare case.
128             -- bso Mon Mar 20 10:37:03 PST 2006
129             --
130             qa_chart_generic_pkg.delete_data(p_chart_id);
131             qa_chart_control_pkg.delete_data(p_chart_id);
132 
133         END CASE;
134 
135     END delete_chart;
136 
137 
138     PROCEDURE create_chart_autonomous(
139         p_criteria_id  NUMBER,
140         p_title        VARCHAR2,
141         p_description  VARCHAR2,
142         p_x_label      VARCHAR2,
143         p_y_label      VARCHAR2,
144         x_chart_id     OUT NOCOPY NUMBER) IS
145 
146     PRAGMA autonomous_transaction;
147 
148     BEGIN
149         create_chart(
150             p_criteria_id,
151             p_title,
152             p_description,
153             p_x_label,
154             p_y_label,
155             x_chart_id);
156         COMMIT;
157     END create_chart_autonomous;
158 
159 
160     PROCEDURE delete_chart_autonomous(p_chart_id NUMBER) IS
161     PRAGMA autonomous_transaction;
162     BEGIN
163         delete_chart(p_chart_id);
164         COMMIT;
165     END delete_chart_autonomous;
166 
167 
168     PROCEDURE set_x_label(p_chart_id NUMBER, p_label VARCHAR2) IS
169     BEGIN
170         UPDATE qa_chart_headers
171         SET    x_label = p_label
172         WHERE  chart_id = p_chart_id;
173     END set_x_label;
174 
175 
176     PROCEDURE set_y_label(p_chart_id NUMBER, p_label VARCHAR2) IS
177     BEGIN
178         UPDATE qa_chart_headers
179         SET    y_label = p_label
180         WHERE  chart_id = p_chart_id;
181     END set_y_label;
182 
183 
184     FUNCTION get_function_axis_label(
185         p_element_id NUMBER,
186         p_function_code NUMBER) RETURN VARCHAR2 IS
187     BEGIN
188         --
189         -- If function code is null, simply return the element
190         -- name, else label is constructed from the message
191         -- QA_CHART_FUNCTION_LABEL
192         --
193         IF p_function_code IS NULL THEN
194             RETURN qa_chars_api.get_element_name(p_element_id);
195         ELSE
196             fnd_message.set_name('QA', 'QA_CHART_FUNCTION_LABEL');
197             fnd_message.set_token('FUNCTION',
198                 qa_eres_util.get_mfg_lookups_meaning(
199                 'QA_FUNCTION', p_function_code));
200             fnd_message.set_token('ELEMENT_NAME',
201                 qa_chars_api.get_element_name(p_element_id));
202             RETURN fnd_message.get;
203         END IF;
204     END get_function_axis_label;
205 
206 END qa_chart_headers_pkg;