DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_CNT_INS

Source


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