DBA Data[Home] [Help]

PACKAGE BODY: APPS.CN_BIS_UTIL_PVT

Source


1 PACKAGE BODY CN_BIS_UTIL_PVT AS
2 -- $Header: cnvbisub.pls 115.1.1158.2 2003/01/21 19:08:15 jjhuang noship $
3 
4 G_PKG_NAME                  CONSTANT VARCHAR2(30)   := 'CN_BIS_UTIL_PVT';
5 G_FILE_NAME                 CONSTANT VARCHAR2(12)   := 'cnvbisub.pls';
6 
7 g_debug_mode                BOOLEAN                 := FALSE;
8 
9 g_parallel_degree           NUMBER                  := 0;
10 
11 -- -------------------------------------------------------------------------+
12 -- set_debug
13 --  Procedure to set the debug mode.
14 --  Access: Public
15 --  Parameters:
16 --      p_debug,      IN, debug mode, either true or false.
17 --  Return:
18 --      None.
19 -- -------------------------------------------------------------------------+
20 PROCEDURE set_debug(p_debug IN BOOLEAN) IS
21 BEGIN
22     IF (p_debug = FALSE OR p_debug IS NULL)
23     THEN
24         g_debug_mode := FALSE;
25     ELSE
26         g_debug_mode := TRUE;
27     END IF;
28 END set_debug;
29 
30 -- -------------------------------------------------------------------------+
31 -- get_debug
32 --  Function to get the debug mode.
33 --  Access: Public
34 --  Parameters:
35 --      None.
36 --  Return:
37 --      TRUE:   debug mode is set.
38 --      FALSE:  debug mode is not set.
39 -- -------------------------------------------------------------------------+
40 FUNCTION get_debug RETURN BOOLEAN IS
41 BEGIN
42     RETURN g_debug_mode;
43 END get_debug;
44 
45 -- -------------------------------------------------------------------------+
46 -- debug_msg
47 --  Procedure to write a message to the concurrent manager output file.
48 --  Access: Public
49 --  Parameters:
50 --      p_message,      IN, The message that will be written to the output file.
51 --      p_indenting,    IN, The number of space for indenting. Default 0.
52 --  Return:
53 --      None.
54 -- -------------------------------------------------------------------------+
55 PROCEDURE debug_msg(p_message IN VARCHAR2, p_indenting IN NUMBER) IS
56 BEGIN
57     IF get_debug = TRUE
58     THEN
59         bis_collection_utilities.debug(p_message, p_indenting);
60         --dbms_output.put_line(p_message);
61     END IF;
62 END debug_msg;
63 
64 -- -------------------------------------------------------------------------+
65 -- log_msg
66 --  Procedure to write a message to the concurrent manager log file using
67 --  BIS_COLLECTION_UTILITIES.log.
68 --  Access: Public
69 --  Parameters:
70 --      p_message,      IN, The message that will be written to the log file.
71 --      p_indenting,    IN, The number of space for indenting. Default 0.
72 --  Return:
73 --      None.
74 -- -------------------------------------------------------------------------+
75 PROCEDURE log_msg(p_message IN VARCHAR2, p_indenting IN NUMBER) IS
76 BEGIN
77     bis_collection_utilities.log(p_message, p_indenting);
78 END log_msg;
79 
80 -- -------------------------------------------------------------------------+
81 -- set_degree_of_parallelism
82 --  Procedure to set the degree of parallelism from BIS common parameters.
83 --  If it's null, then set it to 0.
84 --  Access: Public
85 --  Parameters:
86 --      None.
87 -- -------------------------------------------------------------------------+
88 PROCEDURE set_degree_of_parallelism IS
89 BEGIN
90     g_parallel_degree := bis_common_parameters.get_degree_of_parallelism;
91 
92     IF g_parallel_degree IS NULL
93     THEN
94         g_parallel_degree := 0;
95     END IF;
96 
97     log_msg('Set degree of parallelism : ' || TO_CHAR(g_parallel_degree), 0);
98 END set_degree_of_parallelism;
99 
100 -- -------------------------------------------------------------------------+
101 -- get_degree_of_parallelism
102 --  Function to get the degree of parallelism from BIS common parameters.
103 --  Access: Public
104 --  Parameters:
105 --      None.
106 --  Return:
107 --      NUMBER.
108 -- -------------------------------------------------------------------------+
109 FUNCTION get_degree_of_parallelism RETURN NUMBER IS
110 BEGIN
111     RETURN g_parallel_degree;
112 END get_degree_of_parallelism;
113 
114 -- -------------------------------------------------------------------------+
115 -- enable_parallel
116 --  Procedure to enable parallel.
117 --  Access: Public
118 --  Parameters:
119 --      None.
120 --  Return:
121 --      None.
122 -- -------------------------------------------------------------------------+
123 PROCEDURE enable_parallel IS
124     stm     VARCHAR2(100);
125 BEGIN
126     set_degree_of_parallelism;
127     stm := 'ALTER SESSION FORCE PARALLEL QUERY PARALLEL ' || TO_CHAR(get_degree_of_parallelism);
128     EXECUTE IMMEDIATE stm;
129     log_msg('Parallel enabled.', 0 );
130 END enable_parallel;
131 
132 -- -------------------------------------------------------------------------+
133 -- disable_parallel
134 --  Procedure to disable parallel.
135 --  Access: Public
136 --  Parameters:
137 --      None.
138 --  Return:
139 --      None.
140 -- -------------------------------------------------------------------------+
141 PROCEDURE disable_parallel IS
142     stm     VARCHAR2(100);
143 BEGIN
144     stm := 'ALTER SESSION DISABLE PARALLEL QUERY';
145     EXECUTE IMMEDIATE stm;
146     log_msg('Parallel disabled.', 0 );
147 END disable_parallel;
148 
149 -- -------------------------------------------------------------------------+
150 -- setup
151 --  Function from bis to do setup for runtime profile options.
152 --  Access: Public
153 --  Parameters:
154 --      p_object_name,  IN, an object name to do setup.
155 --  Return:
156 --      TRUE:   setup is successful.
157 --      FALSE:  setup failed.
158 -- -------------------------------------------------------------------------+
159 FUNCTION setup(p_object_name IN VARCHAR2) RETURN BOOLEAN IS
160     l_success BOOLEAN := TRUE;
161 BEGIN
162     IF bis_collection_utilities.setup(p_object_name => p_object_name ) = FALSE
163     THEN
164         l_success := FALSE;
165         log_msg(cn_bis_util_pvt.g_failure_status || cn_bis_util_pvt.g_separator || ' Setup ' || p_object_name, 0);
166         debug_msg(cn_bis_util_pvt.g_failure_status || cn_bis_util_pvt.g_separator || ' Setup ' || p_object_name, 0);
167     ELSE
168         log_msg(cn_bis_util_pvt.g_success_status || cn_bis_util_pvt.g_separator || ' Setup ' || p_object_name, 0);
169         debug_msg(cn_bis_util_pvt.g_success_status || cn_bis_util_pvt.g_separator || ' Setup ' || p_object_name, 0);
170     END IF;
171 
172     RETURN l_success;
173 END setup;
174 
175 -- -------------------------------------------------------------------------+
176 -- wrapup
177 --  Procedure from bis to wrap up the concurrent program using
178 --      bis_collection_utilities.wrapup().
179 --  Access: Public
180 --  Parameters:
181 --      p_status,       IN BOOLEAN, TRUE if the process is a success,
182 --                          FALSE if any of your code failed. You must keep
183 --                          in mind that SETUP and WRAPUP both will commit.
184 --                          So you must rollback before you call these API.
185 --      p_count,        IN NUMBER DEFAULT 0, The number of rows that have been
186 --                          successfully processed. This number is going to be
187 --                          shown in the status viewer form. This number is what
188 --                          the customer will understand as the number of records
189 --                          that your concurrent program processed.
190 --      p_message,      IN VARCHAR2 DEFAULT NULL, If the request were a success,
191 --                          pass null. If there is a failure, pass the error message.
192 --                          This message will be shown in the status viewer form.
193 --      p_period_from,  IN DATE DEFAULT NULL, If you are using from date and
194 --                          to date as the parameters to collect data,
195 --                          populate this parameter.
196 --      p_period_to,    IN DATE DEFAULT NULL, If you are using from date and
197 --                          to date as the parameters to collect data,
198 --                          populate this parameter.
199 --      p_attribute1,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
200 --                          (attribute1 - attribute10), populate this parameter.
201 --      p_attribute2,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
202 --                          (attribute1 - attribute10), populate this parameter.
203 --      p_attribute3,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
204 --                          (attribute1 - attribute10), populate this parameter.
205 --      p_attribute4,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
206 --                          (attribute1 - attribute10), populate this parameter.
207 --      p_attribute5,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
208 --                          (attribute1 - attribute10), populate this parameter.
209 --      p_attribute6,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
210 --                          (attribute1 - attribute10), populate this parameter.
211 --      p_attribute7,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
212 --                          (attribute1 - attribute10), populate this parameter.
213 --      p_attribute8,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
214 --                          (attribute1 - attribute10), populate this parameter.
215 --      p_attribute9,   IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
216 --                          (attribute1 - attribute10), populate this parameter.
217 --      p_attribute10,  IN VARCHAR2 DEFAULT NULL, If you are using flexfield columns
218 --                          (attribute1 - attribute10), populate this parameter.
219 --  Return:
220 --      None.
221 -- -------------------------------------------------------------------------+
222 PROCEDURE wrapup(
223                 p_status             IN BOOLEAN,
224                 p_count              IN NUMBER,
225                 p_message            IN VARCHAR2,
226                 p_period_from        IN DATE,
227                 p_period_to          IN DATE,
228                 p_attribute1         IN VARCHAR2,
229                 p_attribute2         IN VARCHAR2,
230                 p_attribute3         IN VARCHAR2,
231                 p_attribute4         IN VARCHAR2,
232                 p_attribute5         IN VARCHAR2,
233                 p_attribute6         IN VARCHAR2,
234                 p_attribute7         IN VARCHAR2,
235                 p_attribute8         IN VARCHAR2,
236                 p_attribute9         IN VARCHAR2,
237                 p_attribute10        IN VARCHAR2
238                 ) IS
239 BEGIN
240         bis_collection_utilities.wrapup(
241             p_status        => p_status,
242             p_count         => p_count,
243             p_message       => p_message,
244             p_period_from   => p_period_from,
245             p_period_to     => p_period_to,
246             p_attribute1    => p_attribute1,
247             p_attribute2    => p_attribute2,
248             p_attribute3    => p_attribute3,
249             p_attribute4    => p_attribute4,
250             p_attribute5    => p_attribute5,
251             p_attribute6    => p_attribute6,
252             p_attribute7    => p_attribute7,
253             p_attribute8    => p_attribute8,
254             p_attribute9    => p_attribute9,
255             p_attribute10   => p_attribute10
256         );
257 END wrapup;
258 
259 END CN_BIS_UTIL_PVT;