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