DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_QAT_INS

Source


1 Package Body per_qat_ins as
2 /* $Header: peqatrhi.pkb 120.0.12010000.2 2008/11/20 12:27:31 kgowripe ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_qat_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_qat_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_qualifications_tl
66   --
67   insert into per_qualifications_tl
68       (qualification_id
69       ,language
70       ,source_lang
71       ,title
72       ,group_ranking
73       ,license_restrictions
74       ,awarding_body
75       ,grade_attained
76       ,reimbursement_arrangements
77       ,training_completed_units
78       ,membership_category
79       )
80   Values
81     (p_rec.qualification_id
82     ,p_rec.language
83     ,p_rec.source_lang
84     ,p_rec.title
85     ,p_rec.group_ranking
86     ,p_rec.license_restrictions
87     ,p_rec.awarding_body
88     ,p_rec.grade_attained
89     ,p_rec.reimbursement_arrangements
90     ,p_rec.training_completed_units
91     ,p_rec.membership_category
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     per_qat_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     per_qat_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     per_qat_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 per_qat_shd.g_rec_type
157   ,p_qualification_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.qualification_id                 := p_qualification_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_rec                          in per_qat_shd.g_rec_type
204   ) is
205 --
206   l_proc  varchar2(72) := g_package||'post_insert';
207 --
208 Begin
209   hr_utility.set_location('Entering:'||l_proc, 5);
210   begin
211     --
212     per_qat_rki.after_insert
213       (p_qualification_id
214       => p_rec.qualification_id
215       ,p_language
216       => p_rec.language
217       ,p_source_lang
218       => p_rec.source_lang
219       ,p_title
220       => p_rec.title
221       ,p_group_ranking
222       => p_rec.group_ranking
223       ,p_license_restrictions
224       => p_rec.license_restrictions
225       ,p_awarding_body
226       => p_rec.awarding_body
227       ,p_grade_attained
228       => p_rec.grade_attained
229       ,p_reimbursement_arrangements
230       => p_rec.reimbursement_arrangements
231       ,p_training_completed_units
232       => p_rec.training_completed_units
233       ,p_membership_category
234       => p_rec.membership_category
235       );
236     --
237   exception
238     --
239     when hr_api.cannot_find_prog_unit then
240       --
241       hr_api.cannot_find_prog_unit_error
242         (p_module_name => 'PER_QUALIFICATIONS_TL'
243         ,p_hook_type   => 'AI');
244       --
245   end;
246   --
247   hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End post_insert;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< ins >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure ins
254   (p_rec                          in out nocopy per_qat_shd.g_rec_type
255   ,p_qualification_id             in number
256   ) is
257 --
258   l_proc  varchar2(72) := g_package||'ins';
259 --
260 Begin
261   hr_utility.set_location('Entering:'||l_proc, 5);
262   --
263   --
264   -- Call the supporting insert validate operations
265   --
266   per_qat_bus.insert_validate
267     (p_rec                         => p_rec
268     ,p_qualification_id            => p_qualification_id
269     );
270   --
271   -- Call to raise any errors on multi-message list
272   hr_multi_message.end_validation_set;
273   --
274   -- Call the supporting pre-insert operation
275   --
276   per_qat_ins.pre_insert
277     (p_rec                         => p_rec
278     ,p_qualification_id            => p_qualification_id
279     );
280   --
281   -- Insert the row
282   --
283   per_qat_ins.insert_dml(p_rec);
284   --
285   -- Call the supporting post-insert operation
286   --
287   per_qat_ins.post_insert
288      (p_rec
289      );
290   --
291   -- Call to raise any errors on multi-message list
292   hr_multi_message.end_validation_set;
293   --
294   hr_utility.set_location('Leaving:'||l_proc, 20);
295 end ins;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |---------------------------------< ins >----------------------------------|
299 -- ----------------------------------------------------------------------------
300 Procedure ins
301   (p_qualification_id               in     number
302   ,p_language                       in     varchar2
303   ,p_source_lang                    in     varchar2
304   ,p_title                          in     varchar2
305   ,p_group_ranking                  in     varchar2
306   ,p_license_restrictions           in     varchar2
307   ,p_awarding_body                  in     varchar2
308   ,p_grade_attained                 in     varchar2
309   ,p_reimbursement_arrangements     in     varchar2
310   ,p_training_completed_units       in     varchar2
311   ,p_membership_category            in     varchar2
312   ) is
313 --
314   l_rec   per_qat_shd.g_rec_type;
315   l_proc  varchar2(72) := g_package||'ins';
316 --
317 Begin
318   hr_utility.set_location('Entering:'||l_proc, 5);
319   --
320   -- Call conversion function to turn arguments into the
321   -- p_rec structure.
322   --
323   l_rec :=
324   per_qat_shd.convert_args
325     (null
326     ,p_language
327     ,p_source_lang
328     ,p_title
329     ,p_group_ranking
330     ,p_license_restrictions
331     ,p_awarding_body
332     ,p_grade_attained
333     ,p_reimbursement_arrangements
334     ,p_training_completed_units
335     ,p_membership_category
336     );
337   --
338   -- Having converted the arguments into the per_qat_rec
339   -- plsql record structure we call the corresponding record business process.
340   --
341   per_qat_ins.ins
342      (p_rec                         => l_rec
343      ,p_qualification_id            => p_qualification_id
344      );
345   --
346   -- As the primary key argument(s)
347   -- are specified as an OUT's we must set these values.
348   --
349   --
350   --
351   hr_utility.set_location(' Leaving:'||l_proc, 10);
352 End ins;
353 --
354 -- ----------------------------------------------------------------------------
355 -- |------------------------------< ins_tl >----------------------------------|
356 -- ----------------------------------------------------------------------------
357 Procedure ins_tl
358   (p_language_code               in varchar2
359   ,p_qualification_id             in number
360   ,p_title                        in varchar2 default null
361   ,p_group_ranking                in varchar2 default null
362   ,p_license_restrictions         in varchar2 default null
363   ,p_awarding_body                in varchar2 default null
364   ,p_grade_attained               in varchar2 default null
365   ,p_reimbursement_arrangements   in varchar2 default null
366   ,p_training_completed_units     in varchar2 default null
367   ,p_membership_category          in varchar2 default null
368   ) is
369   --
370   -- Cursor to obtain the list of base and installed languages
371   --
372   cursor csr_ins_langs is
373     select l.language_code
374       from fnd_languages l
375      where l.installed_flag in ('I','B')
376        and not exists (select null
377                          from per_qualifications_tl qat
378                         where qat.qualification_id = p_qualification_id
379                           and qat.language = l.language_code);
380   --
381   l_proc  varchar2(72)  := g_package || 'ins_tl';
382   --
383 Begin
384   hr_utility.set_location('Entering:'||l_proc,10);
385   --
386   -- Insert a row for the base language and every installed language.
387   --
388   for l_lang in csr_ins_langs loop
389     per_qat_ins.ins
390       (p_qualification_id            => p_qualification_id
391       ,p_language                    => l_lang.language_code
392       ,p_source_lang                 => p_language_code
393       ,p_title                       => p_title
394       ,p_group_ranking               => p_group_ranking
395       ,p_license_restrictions        => p_license_restrictions
396       ,p_awarding_body               => p_awarding_body
397       ,p_grade_attained              => p_grade_attained
398       ,p_reimbursement_arrangements  => p_reimbursement_arrangements
399       ,p_training_completed_units    => p_training_completed_units
400       ,p_membership_category         => p_membership_category
401       );
402   end loop;
403   --
404   hr_utility.set_location('Leaving:'||l_proc,20);
405 End ins_tl;
406 --
407 end per_qat_ins;