1 Package Body pqp_ert_ins as
2 /* $Header: pqertrhi.pkb 120.7 2006/09/15 00:09:58 sshetty noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqp_ert_ins.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml insert logic. The processing of
17 -- this procedure are as follows:
18 -- 1) Initialise the object_version_number to 1 if the object_version_number
19 -- is defined as an attribute for this entity.
20 -- 2) To set and unset the g_api_dml status as required (as we are about to
21 -- perform dml).
22 -- 3) To insert the row into the schema.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Prerequisites:
27 -- This is an internal private procedure which must be called from the ins
28 -- procedure and must have all mandatory attributes set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 -- On the insert dml failure it is important to note that we always reset the
39 -- g_api_dml status to false.
40 -- If a check, unique or parent integrity constraint violation is raised the
41 -- constraint_error procedure will be called.
42 -- If any other error is reported, the error will be raised after the
43 -- g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 -- None.
47 --
48 -- Access Status:
49 -- Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml
54 (p_rec in out nocopy pqp_ert_shd.g_rec_type
55 ) is
56 --
57 l_proc varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60 hr_utility.set_location('Entering:'||l_proc, 5);
61 --
62 pqp_ert_shd.g_api_dml := true; -- Set the api dml status
63 --
64 -- Insert the row into: pqp_exception_reports_tl
65 --
66
67 IF hr_startup_data_api_support.g_startup_mode NOT IN ('GENERIC','STARTUP')
68 THEN
69
70 insert into pqp_exception_reports_tl
71 (exception_report_id
72 ,exception_report_name
73 ,language
74 ,source_lang
75 )
76 Values
77 (p_rec.exception_report_id
78 ,p_rec.exception_report_name
79 ,p_rec.language
80 ,p_rec.source_lang
81 );
82
83 ELSE
84
85 insert into pqp_exception_reports_tl
86 (exception_report_id
87 ,exception_report_name
88 ,language
89 ,source_lang
90 ,last_updated_by
91 ,last_update_date
92 ,created_by
93 ,creation_date
94 )
95 Values
96 (p_rec.exception_report_id
97 ,p_rec.exception_report_name
98 ,p_rec.language
99 ,p_rec.source_lang
100 ,2
101 ,sysdate
102 ,2
103 ,sysdate
104 );
105
106 END IF;
107 --
108 pqp_ert_shd.g_api_dml := false; -- Unset the api dml status
109 --
110 hr_utility.set_location(' Leaving:'||l_proc, 10);
111 Exception
112 When hr_api.check_integrity_violated Then
113 -- A check constraint has been violated
114 pqp_ert_shd.g_api_dml := false; -- Unset the api dml status
115 pqp_ert_shd.constraint_error
116 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117 When hr_api.parent_integrity_violated Then
118 -- Parent integrity has been violated
119 pqp_ert_shd.g_api_dml := false; -- Unset the api dml status
120 pqp_ert_shd.constraint_error
121 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122 When hr_api.unique_integrity_violated Then
123 -- Unique integrity has been violated
124 pqp_ert_shd.g_api_dml := false; -- Unset the api dml status
125 pqp_ert_shd.constraint_error
126 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127 When Others Then
128 pqp_ert_shd.g_api_dml := false; -- Unset the api dml status
129 Raise;
130 End insert_dml;
131 --
132 -- ----------------------------------------------------------------------------
133 -- |------------------------------< pre_insert >------------------------------|
134 -- ----------------------------------------------------------------------------
135 -- {Start Of Comments}
136 --
137 -- Description:
138 -- This private procedure contains any processing which is required before
139 -- the insert dml. Presently, if the entity has a corresponding primary
140 -- key which is maintained by an associating sequence, the primary key for
141 -- the entity will be populated with the next sequence value in
142 -- preparation for the insert dml.
143 --
144 -- Prerequisites:
145 -- This is an internal procedure which is called from the ins procedure.
146 --
147 -- In Parameters:
148 -- A Pl/Sql record structre.
149 --
150 -- Post Success:
151 -- Processing continues.
152 --
153 -- Post Failure:
154 -- If an error has occurred, an error message and exception will be raised
155 -- but not handled.
156 --
157 -- Developer Implementation Notes:
158 -- Any pre-processing required before the insert dml is issued should be
159 -- coded within this procedure. As stated above, a good example is the
160 -- generation of a primary key number via a corresponding sequence.
161 -- It is important to note that any 3rd party maintenance should be reviewed
162 -- before placing in this procedure.
163 --
164 -- Access Status:
165 -- Internal Row Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure pre_insert
170 (p_rec in out nocopy pqp_ert_shd.g_rec_type
171 ,p_exception_report_id in number
172 ) is
173 --
174 l_proc varchar2(72) := g_package||'pre_insert';
175 --
176 Begin
177 hr_utility.set_location('Entering:'||l_proc, 5);
178 --
179 p_rec.exception_report_id := p_exception_report_id;
180 --
181 hr_utility.set_location(' Leaving:'||l_proc, 10);
182 End pre_insert;
183 --
184 -- ----------------------------------------------------------------------------
185 -- |-----------------------------< post_insert >------------------------------|
186 -- ----------------------------------------------------------------------------
187 -- {Start Of Comments}
188 --
189 -- Description:
190 -- This private procedure contains any processing which is required after
191 -- the insert dml.
192 --
193 -- Prerequisites:
194 -- This is an internal procedure which is called from the ins procedure.
195 --
196 -- In Parameters:
197 -- A Pl/Sql record structre.
198 --
199 -- Post Success:
200 -- Processing continues.
201 --
202 -- Post Failure:
203 -- If an error has occurred, an error message and exception will be raised
204 -- but not handled.
205 --
206 -- Developer Implementation Notes:
207 -- Any post-processing required after the insert dml is issued should be
208 -- coded within this procedure. It is important to note that any 3rd party
209 -- maintenance should be reviewed before placing in this procedure.
210 --
211 -- Access Status:
212 -- Internal Row Handler Use Only.
213 --
214 -- {End Of Comments}
215 -- ----------------------------------------------------------------------------
216 Procedure post_insert
217 (p_rec in pqp_ert_shd.g_rec_type
218 ) is
219 --
220 l_proc varchar2(72) := g_package||'post_insert';
221 --
222 Begin
223 hr_utility.set_location('Entering:'||l_proc, 5);
224 begin
225 --
226 pqp_ert_rki.after_insert (
227 p_exception_report_id
228 => p_rec.exception_report_id
229 ,p_exception_report_name
230 => p_rec.exception_report_name
231 ,p_language
232 => p_rec.language
233 ,p_source_lang
234 => p_rec.source_lang
235 );
236 --
237 exception
238 --
239 when hr_api.cannot_find_prog_unit then
240 --
241 hr_api.cannot_find_prog_unit_error
242 (p_module_name => 'PQP_EXCEPTION_REPORTS_TL'
243 ,p_hook_type => 'AI');
244 --
245 end;
246 --
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End post_insert;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< ins >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure ins
254 (p_rec in out nocopy pqp_ert_shd.g_rec_type
255 ,p_exception_report_id in number
256 ) is
257 --
258 l_proc varchar2(72) := g_package||'ins';
259 --
260 Begin
261 hr_utility.set_location('Entering:'||l_proc, 5);
262 --
263 -- Call the supporting insert validate operations
264 --
265 pqp_ert_bus.insert_validate
266 (p_rec
267 );
268 --
269 -- Call the supporting pre-insert operation
270 --
271 pqp_ert_ins.pre_insert
272 (p_rec => p_rec
273 ,p_exception_report_id => p_exception_report_id
274 );
275 --
276 -- Insert the row
277 --
278 pqp_ert_ins.insert_dml(p_rec);
279 --
280 -- Call the supporting post-insert operation
281 --
282 pqp_ert_ins.post_insert
283 (p_rec
284 );
285 --
286 hr_utility.set_location('Leaving:'||l_proc, 20);
287 end ins;
288 --
289 -- ----------------------------------------------------------------------------
290 -- |---------------------------------< ins >----------------------------------|
291 -- ----------------------------------------------------------------------------
292 Procedure ins
293 (p_exception_report_id in number
294 ,p_exception_report_name in varchar2
295 ,p_language in varchar2
296 ,p_source_lang in varchar2
297 ) is
298 --
299 l_rec pqp_ert_shd.g_rec_type;
300 l_proc varchar2(72) := g_package||'ins';
301 --
302 Begin
303 hr_utility.set_location('Entering:'||l_proc, 5);
304 --
305 -- Call conversion function to turn arguments into the
306 -- p_rec structure.
307 --
308 l_rec :=
309 pqp_ert_shd.convert_args
310 (p_exception_report_id
311 ,p_exception_report_name
312 ,p_language
313 ,p_source_lang
314 );
315 --
316 -- Having converted the arguments into the pqp_ert_rec
317 -- plsql record structure we call the corresponding record business process.
318 --
319 pqp_ert_ins.ins
320 (p_rec => l_rec
321 ,p_exception_report_id => p_exception_report_id
322 );
323 --
324 -- As the primary key argument(s)
325 -- are specified as an OUT's we must set these values.
326 --
327 --
328 hr_utility.set_location(' Leaving:'||l_proc, 10);
329 End ins;
330 --
331 -- ----------------------------------------------------------------------------
332 -- |------------------------------< ins_tl >----------------------------------|
333 -- ----------------------------------------------------------------------------
334 Procedure ins_tl
335 (p_language_code in varchar2
336 ,p_exception_report_id in number
337 ,p_exception_report_name in varchar2
338 ) is
339 --
340 -- Cursor to obtain the list of base and installed languages
341 --
342 cursor csr_ins_langs is
343 select l.language_code
344 from fnd_languages l
345 where l.installed_flag in ('I','B')
346 and not exists (select null
347 from pqp_exception_reports_tl ert
348 where ert.exception_report_id = p_exception_report_id
349 and ert.language = l.language_code);
350 --
351 l_proc varchar2(72) := g_package || 'ins_tl';
352 --
353 Begin
354 hr_utility.set_location('Entering:'||l_proc,10);
355 --
356 -- Insert a row for the base language and every installed language.
357 --
358 for l_lang in csr_ins_langs loop
359 pqp_ert_ins.ins
360 (p_exception_report_id => p_exception_report_id
361 ,p_language => l_lang.language_code
362 ,p_source_lang => p_language_code
363 ,p_exception_report_name => p_exception_report_name
364 );
365 end loop;
366 --
367 hr_utility.set_location('Leaving:'||l_proc,20);
368 End ins_tl;
369 --
370 end pqp_ert_ins;