1 Package Body ota_ctl_ins as
2 /* $Header: otctlrhi.pkb 120.2 2005/12/01 16:42 cmora noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_ctl_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 ota_ctl_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 --
63 --
64 --
65 -- Insert the row into: ota_certifications_tl
66 --
67 insert into ota_certifications_tl
68 (certification_id
69 ,language
70 ,name
71 ,description
72 ,objectives
73 ,purpose
74 ,keywords
75 ,end_date_comments
76 ,initial_period_comments
77 ,renewal_period_comments
78 ,source_lang
79 )
80 Values
81 (p_rec.certification_id
82 ,p_rec.language
83 ,p_rec.name
84 ,p_rec.description
85 ,p_rec.objectives
86 ,p_rec.purpose
87 ,p_rec.keywords
88 ,p_rec.end_date_comments
89 ,p_rec.initial_period_comments
90 ,p_rec.renewal_period_comments
91 ,p_rec.source_lang
92 );
93 --
94 --
95 --
96 hr_utility.set_location(' Leaving:'||l_proc, 10);
97 Exception
98 When hr_api.check_integrity_violated Then
99 -- A check constraint has been violated
100 --
101 ota_ctl_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When hr_api.parent_integrity_violated Then
104 -- Parent integrity has been violated
105 --
106 ota_ctl_shd.constraint_error
107 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108 When hr_api.unique_integrity_violated Then
109 -- Unique integrity has been violated
110 --
111 ota_ctl_shd.constraint_error
112 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113 When Others Then
114 --
115 Raise;
116 End insert_dml;
117 --
118 -- ----------------------------------------------------------------------------
119 -- |------------------------------< pre_insert >------------------------------|
120 -- ----------------------------------------------------------------------------
121 -- {Start Of Comments}
122 --
123 -- Description:
124 -- This private procedure contains any processing which is required before
125 -- the insert dml. Presently, if the entity has a corresponding primary
126 -- key which is maintained by an associating sequence, the primary key for
127 -- the entity will be populated with the next sequence value in
128 -- preparation for the insert dml.
129 --
130 -- Prerequisites:
131 -- This is an internal procedure which is called from the ins procedure.
132 --
133 -- In Parameters:
134 -- A Pl/Sql record structre.
135 --
136 -- Post Success:
137 -- Processing continues.
138 --
139 -- Post Failure:
140 -- If an error has occurred, an error message and exception will be raised
141 -- but not handled.
142 --
143 -- Developer Implementation Notes:
144 -- Any pre-processing required before the insert dml is issued should be
145 -- coded within this procedure. As stated above, a good example is the
146 -- generation of a primary key number via a corresponding sequence.
147 -- It is important to note that any 3rd party maintenance should be reviewed
148 -- before placing in this procedure.
149 --
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure pre_insert
156 (p_rec in out nocopy ota_ctl_shd.g_rec_type
157 ,p_certification_id in number
158 ) is
159 --
160 l_proc varchar2(72) := g_package||'pre_insert';
161 --
162 Begin
163 hr_utility.set_location('Entering:'||l_proc, 5);
164 --
165 p_rec.certification_id := p_certification_id;
166 --
167 hr_utility.set_location(' Leaving:'||l_proc, 10);
168 End pre_insert;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |-----------------------------< post_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 -- This private procedure contains any processing which is required after
177 -- the insert dml.
178 --
179 -- Prerequisites:
180 -- This is an internal procedure which is called from the ins procedure.
181 --
182 -- In Parameters:
183 -- A Pl/Sql record structre.
184 --
185 -- Post Success:
186 -- Processing continues.
187 --
188 -- Post Failure:
189 -- If an error has occurred, an error message and exception will be raised
190 -- but not handled.
191 --
192 -- Developer Implementation Notes:
193 -- Any post-processing required after the insert dml is issued should be
194 -- coded within this procedure. It is important to note that any 3rd party
195 -- maintenance should be reviewed before placing in this procedure.
196 --
197 -- Access Status:
198 -- Internal Row Handler Use Only.
199 --
200 -- {End Of Comments}
201 -- ----------------------------------------------------------------------------
202 Procedure post_insert
203 (p_effective_date in date
204 ,p_rec in ota_ctl_shd.g_rec_type
205 ) is
206 --
207 l_proc varchar2(72) := g_package||'post_insert';
208 --
209 Begin
210 hr_utility.set_location('Entering:'||l_proc, 5);
211 begin
212 --
213 ota_ctl_rki.after_insert
214 (p_effective_date => p_effective_date
215 ,p_certification_id
216 => p_rec.certification_id
217 ,p_language
218 => p_rec.language
219 ,p_name
220 => p_rec.name
221 ,p_description
222 => p_rec.description
223 ,p_objectives
224 => p_rec.objectives
225 ,p_purpose
226 => p_rec.purpose
227 ,p_keywords
228 => p_rec.keywords
229 ,p_end_date_comments
230 => p_rec.end_date_comments
231 ,p_initial_period_comments
232 => p_rec.initial_period_comments
233 ,p_renewal_period_comments
234 => p_rec.renewal_period_comments
235 ,p_source_lang
236 => p_rec.source_lang
237 );
238 --
239 exception
240 --
241 when hr_api.cannot_find_prog_unit then
242 --
243 hr_api.cannot_find_prog_unit_error
244 (p_module_name => 'OTA_CERTIFICATIONS_TL'
245 ,p_hook_type => 'AI');
246 --
247 end;
248 --
249 hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End post_insert;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |---------------------------------< ins >----------------------------------|
254 -- ----------------------------------------------------------------------------
255 Procedure ins
256 (p_effective_date in date
257 ,p_rec in out nocopy ota_ctl_shd.g_rec_type
258 ,p_certification_id in number
259 ) is
260 --
261 l_proc varchar2(72) := g_package||'ins';
262 --
263 Begin
264 hr_utility.set_location('Entering:'||l_proc, 5);
265 --
266 -- Call the supporting insert validate operations
267 --
268 --Modified for Bug#4775354
269 ota_ctl_bus.insert_validate
270 (p_effective_date
271 ,p_rec
272 ,p_certification_id
273 );
274 --
275 -- Call to raise any errors on multi-message list
276 hr_multi_message.end_validation_set;
277 --
278 -- Call the supporting pre-insert operation
279 --
280 ota_ctl_ins.pre_insert
281 (p_rec => p_rec
282 ,p_certification_id => p_certification_id
283 );
284 --
285 -- Insert the row
286 --
287 ota_ctl_ins.insert_dml(p_rec);
288 --
289 -- Call the supporting post-insert operation
290 --
291 ota_ctl_ins.post_insert
292 (p_effective_date
293 ,p_rec
294 );
295 --
296 -- Call to raise any errors on multi-message list
297 hr_multi_message.end_validation_set;
298 --
299 hr_utility.set_location('Leaving:'||l_proc, 20);
300 end ins;
301 --
302 -- ----------------------------------------------------------------------------
303 -- |---------------------------------< ins >----------------------------------|
304 -- ----------------------------------------------------------------------------
305 Procedure ins
306 (p_effective_date in date
307 ,p_certification_id in number
308 ,p_language in varchar2
309 ,p_name in varchar2
310 ,p_source_lang in varchar2
311 ,p_description in varchar2
312 ,p_objectives in varchar2
313 ,p_purpose in varchar2
314 ,p_keywords in varchar2
315 ,p_end_date_comments in varchar2
316 ,p_initial_period_comments in varchar2
317 ,p_renewal_period_comments in varchar2
318 ) is
319 --
320 l_rec ota_ctl_shd.g_rec_type;
321 l_proc varchar2(72) := g_package||'ins';
322 --
323 Begin
324 hr_utility.set_location('Entering:'||l_proc, 5);
325 --
326 -- Call conversion function to turn arguments into the
327 -- p_rec structure.
328 --
329 l_rec :=
330 ota_ctl_shd.convert_args
331 (null
332 ,p_language
333 ,p_name
334 ,p_description
335 ,p_objectives
336 ,p_purpose
337 ,p_keywords
338 ,p_end_date_comments
339 ,p_initial_period_comments
340 ,p_renewal_period_comments
341 ,p_source_lang
342 );
343 --
344 -- Having converted the arguments into the ota_ctl_rec
345 -- plsql record structure we call the corresponding record business process.
346 --
347 ota_ctl_ins.ins
348 (p_effective_date => p_effective_date
349 ,p_rec => l_rec
350 ,p_certification_id => p_certification_id
351 );
352 --
353 -- As the primary key argument(s)
354 -- are specified as an OUT's we must set these values.
355 --
356 --
357 --
358 hr_utility.set_location(' Leaving:'||l_proc, 10);
359 End ins;
360 --
361 -- ----------------------------------------------------------------------------
362 -- |------------------------------< ins_tl >----------------------------------|
363 -- ----------------------------------------------------------------------------
364 Procedure ins_tl
365 (p_effective_date in date
366 ,p_language_code in varchar2
367 ,p_certification_id in number
368 ,p_name in varchar2
369 ,p_description in varchar2 default null
370 ,p_objectives in varchar2 default null
371 ,p_purpose in varchar2 default null
372 ,p_keywords in varchar2 default null
373 ,p_end_date_comments in varchar2 default null
374 ,p_initial_period_comments in varchar2 default null
375 ,p_renewal_period_comments in varchar2 default null
376 ) is
377 --
378 -- Cursor to obtain the list of base and installed languages
379 --
380 cursor csr_ins_langs is
381 select l.language_code
382 from fnd_languages l
383 where l.installed_flag in ('I','B')
384 and not exists (select null
388 --
385 from ota_certifications_tl ctl
386 where ctl.certification_id = p_certification_id
387 and ctl.language = l.language_code);
389 l_proc varchar2(72) := g_package || 'ins_tl';
390 --
391 Begin
392 hr_utility.set_location('Entering:'||l_proc,10);
393 --
394 -- Insert a row for the base language and every installed language.
395 --
396 for l_lang in csr_ins_langs loop
397 ota_ctl_ins.ins
398 (p_effective_date => p_effective_date
399 ,p_certification_id => p_certification_id
400 ,p_language => l_lang.language_code
401 ,p_source_lang => p_language_code
402 ,p_name => p_name
403 ,p_description => p_description
404 ,p_objectives => p_objectives
405 ,p_purpose => p_purpose
406 ,p_keywords => p_keywords
407 ,p_end_date_comments => p_end_date_comments
408 ,p_initial_period_comments => p_initial_period_comments
409 ,p_renewal_period_comments => p_renewal_period_comments
410 );
411 end loop;
412 --
413 hr_utility.set_location('Leaving:'||l_proc,20);
414 End ins_tl;
415 --
416 end ota_ctl_ins;