DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_LPT_INS

Source


4 -- ----------------------------------------------------------------------------
1 Package Body ota_lpt_ins as
2 /* $Header: otlptrhi.pkb 120.0 2005/05/29 07:24:49 appldev noship $ */
3 --
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_lpt_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_lpt_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_learning_paths_tl
66   --
67   insert into ota_learning_paths_tl
68       (learning_path_id
69       ,language
70       ,name
71       ,description
72       ,objectives
73       ,purpose
74       ,keywords
75       ,source_lang
76       )
77   Values
78     (p_rec.learning_path_id
79     ,p_rec.language
80     ,p_rec.name
81     ,p_rec.description
82     ,p_rec.objectives
83     ,p_rec.purpose
84     ,p_rec.keywords
85     ,p_rec.source_lang
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_lpt_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_lpt_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_lpt_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_lpt_shd.g_rec_type
151   ,p_learning_path_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.learning_path_id                 := p_learning_path_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_lpt_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_lpt_rki.after_insert
208       (p_effective_date              => p_effective_date
209       ,p_learning_path_id
210       => p_rec.learning_path_id
211       ,p_language
212       => p_rec.language
213       ,p_name
214       => p_rec.name
215       ,p_description
216       => p_rec.description
217       ,p_objectives
218       => p_rec.objectives
219       ,p_purpose
220       => p_rec.purpose
221       ,p_keywords
222       => p_rec.keywords
223       ,p_source_lang
224       => p_rec.source_lang
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_LEARNING_PATHS_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_lpt_shd.g_rec_type
246   ,p_learning_path_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   --Modified for Bug#4310348
257   ota_lpt_bus.insert_validate
258      (p_effective_date
259      ,p_rec
260      ,p_learning_path_id
261      );
262   --
263   -- Call to raise any errors on multi-message list
264   hr_multi_message.end_validation_set;
265   --
266   -- Call the supporting pre-insert operation
267   --
268   ota_lpt_ins.pre_insert
269     (p_rec                         => p_rec
270     ,p_learning_path_id            => p_learning_path_id
271     );
272   --
273   -- Insert the row
274   --
275   ota_lpt_ins.insert_dml(p_rec);
276   --
277   -- Call the supporting post-insert operation
278   --
279   ota_lpt_ins.post_insert
280      (p_effective_date
281      ,p_rec
282      );
283   --
284   -- Call to raise any errors on multi-message list
285   hr_multi_message.end_validation_set;
286   --
287   hr_utility.set_location('Leaving:'||l_proc, 20);
288 end ins;
289 --
290 -- ----------------------------------------------------------------------------
291 -- |---------------------------------< ins >----------------------------------|
292 -- ----------------------------------------------------------------------------
293 Procedure ins
294   (p_effective_date               in date
295   ,p_learning_path_id               in     number
296   ,p_language                       in     varchar2
297   ,p_name                           in     varchar2
298   ,p_description                    in     varchar2
299   ,p_objectives                     in     varchar2
300   ,p_purpose                        in     varchar2
304 --
301   ,p_keywords                       in     varchar2
302   ,p_source_lang                    in     varchar2
303   ) is
305   l_rec   ota_lpt_shd.g_rec_type;
306   l_proc  varchar2(72) := g_package||'ins';
307 --
308 Begin
309   hr_utility.set_location('Entering:'||l_proc, 5);
310   --
311   -- Call conversion function to turn arguments into the
312   -- p_rec structure.
313   --
314   l_rec :=
315   ota_lpt_shd.convert_args
316     (null
317     ,p_language
318     ,p_name
319     ,p_description
320     ,p_objectives
321     ,p_purpose
322     ,p_keywords
323     ,p_source_lang
324     );
325   --
326   -- Having converted the arguments into the ota_lpt_rec
327   -- plsql record structure we call the corresponding record business process.
328   --
329   ota_lpt_ins.ins
330      (p_effective_date              => p_effective_date
331       ,p_rec                         => l_rec
332      ,p_learning_path_id            => p_learning_path_id
333      );
334   --
335   -- As the primary key argument(s)
336   -- are specified as an OUT's we must set these values.
337   --
338   --
339   --
340   hr_utility.set_location(' Leaving:'||l_proc, 10);
341 End ins;
342 --
343 -- ----------------------------------------------------------------------------
344 -- |------------------------------< ins_tl >----------------------------------|
345 -- ----------------------------------------------------------------------------
346 Procedure ins_tl
347   (p_effective_date               in date
348   ,p_language_code               in varchar2
349   ,p_learning_path_id             in number
350   ,p_name                         in varchar2
351   ,p_description                  in varchar2 default null
352   ,p_objectives                   in varchar2 default null
353   ,p_purpose                      in varchar2 default null
354   ,p_keywords                     in varchar2 default null
355   ) is
356   --
357   -- Cursor to obtain the list of base and installed languages
358   --
359   cursor csr_ins_langs is
360     select l.language_code
361       from fnd_languages l
362      where l.installed_flag in ('I','B')
363        and not exists (select null
364                          from ota_learning_paths_tl lpt
365                         where lpt.learning_path_id = p_learning_path_id
366                           and lpt.language = l.language_code);
367   --
368   l_proc  varchar2(72)  := g_package || 'ins_tl';
369   --
370 Begin
371   hr_utility.set_location('Entering:'||l_proc,10);
372   --
373   -- Insert a row for the base language and every installed language.
374   --
375   for l_lang in csr_ins_langs loop
376     ota_lpt_ins.ins
377       (p_effective_date              => p_effective_date
378       ,p_learning_path_id            => p_learning_path_id
379       ,p_language                    => l_lang.language_code
380       ,p_source_lang                 => p_language_code
381       ,p_name                        => p_name
382       ,p_description                 => p_description
383       ,p_objectives                  => p_objectives
384       ,p_purpose                     => p_purpose
385       ,p_keywords                    => p_keywords
386       );
387   end loop;
388   --
389   hr_utility.set_location('Leaving:'||l_proc,20);
390 End ins_tl;
391 --
392 end ota_lpt_ins;