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