DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PRV_INS

Source


1 Package Body per_prv_ins as
2 /* $Header: peprvrhi.pkb 120.1 2006/04/14 17:27:46 kandra noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_prv_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.
23 --   4) To trap any constraint violations that may have occurred.
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.
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(p_rec in out nocopy per_prv_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   per_prv_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: per_performance_reviews
64   --
65   insert into per_performance_reviews
66   (	performance_review_id,
67 	person_id,
68 	event_id,
69 	review_date,
70 	performance_rating,
71 	next_perf_review_date,
72 	attribute_category,
73 	attribute1,
74 	attribute2,
75 	attribute3,
76 	attribute4,
77 	attribute5,
78 	attribute6,
79 	attribute7,
80 	attribute8,
81 	attribute9,
82 	attribute10,
83 	attribute11,
84 	attribute12,
85 	attribute13,
86 	attribute14,
87 	attribute15,
88 	attribute16,
89 	attribute17,
90 	attribute18,
91 	attribute19,
92 	attribute20,
93 	attribute21,
94 	attribute22,
95 	attribute23,
96 	attribute24,
97 	attribute25,
98 	attribute26,
99 	attribute27,
100 	attribute28,
101 	attribute29,
102 	attribute30,
103 	object_version_number
104   )
105   Values
106   (	p_rec.performance_review_id,
107 	p_rec.person_id,
108 	p_rec.event_id,
109 	p_rec.review_date,
110 	p_rec.performance_rating,
111 	p_rec.next_perf_review_date,
112 	p_rec.attribute_category,
113 	p_rec.attribute1,
114 	p_rec.attribute2,
115 	p_rec.attribute3,
116 	p_rec.attribute4,
117 	p_rec.attribute5,
118 	p_rec.attribute6,
119 	p_rec.attribute7,
120 	p_rec.attribute8,
121 	p_rec.attribute9,
122 	p_rec.attribute10,
123 	p_rec.attribute11,
124 	p_rec.attribute12,
125 	p_rec.attribute13,
126 	p_rec.attribute14,
127 	p_rec.attribute15,
128 	p_rec.attribute16,
129 	p_rec.attribute17,
130 	p_rec.attribute18,
131 	p_rec.attribute19,
132 	p_rec.attribute20,
133 	p_rec.attribute21,
134 	p_rec.attribute22,
135 	p_rec.attribute23,
136 	p_rec.attribute24,
137 	p_rec.attribute25,
138 	p_rec.attribute26,
139 	p_rec.attribute27,
140 	p_rec.attribute28,
141 	p_rec.attribute29,
142 	p_rec.attribute30,
143 	p_rec.object_version_number
144   );
145   --
146   per_prv_shd.g_api_dml := false;   -- Unset the api dml status
147   --
148   hr_utility.set_location(' Leaving:'||l_proc, 10);
149 Exception
150   When hr_api.check_integrity_violated Then
151     -- A check constraint has been violated
152     per_prv_shd.g_api_dml := false;   -- Unset the api dml status
153     per_prv_shd.constraint_error
154       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
155   When hr_api.parent_integrity_violated Then
156     -- Parent integrity has been violated
157     per_prv_shd.g_api_dml := false;   -- Unset the api dml status
158     per_prv_shd.constraint_error
159       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
160   When hr_api.unique_integrity_violated Then
161     -- Unique integrity has been violated
162     per_prv_shd.g_api_dml := false;   -- Unset the api dml status
163     per_prv_shd.constraint_error
164       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
165   When Others Then
166     per_prv_shd.g_api_dml := false;   -- Unset the api dml status
167     Raise;
168 End insert_dml;
169 --
170 -- ----------------------------------------------------------------------------
171 -- |------------------------------< pre_insert >------------------------------|
172 -- ----------------------------------------------------------------------------
173 -- {Start Of Comments}
174 --
175 -- Description:
176 --   This private procedure contains any processing which is required before
177 --   the insert dml. Presently, if the entity has a corresponding primary
178 --   key which is maintained by an associating sequence, the primary key for
179 --   the entity will be populated with the next sequence value in
180 --   preparation for the insert dml.
181 --
182 -- Prerequisites:
183 --   This is an internal procedure which is called from the ins procedure.
184 --
185 -- In Parameters:
186 --   A Pl/Sql record structre.
187 --
188 -- Post Success:
189 --   Processing continues.
190 --
191 -- Post Failure:
192 --   If an error has occurred, an error message and exception will be raised
193 --   but not handled.
194 --
195 -- Developer Implementation Notes:
196 --   Any pre-processing required before the insert dml is issued should be
197 --   coded within this procedure. As stated above, a good example is the
198 --   generation of a primary key number via a corresponding sequence.
199 --   It is important to note that any 3rd party maintenance should be reviewed
200 --   before placing in this procedure.
201 --
202 -- Access Status:
203 --   Internal Row Handler Use Only.
204 --
205 -- {End Of Comments}
206 -- ----------------------------------------------------------------------------
207 Procedure pre_insert(p_rec  in out nocopy per_prv_shd.g_rec_type) is
208 --
209   l_proc  varchar2(72) := g_package||'pre_insert';
210 --
211   cursor c_next_id is
212   select per_performance_reviews_s.nextval
213   from sys.dual;
214 --
215 --
216 Begin
217   hr_utility.set_location('Entering:'||l_proc, 5);
218   --
219   --
220   open  c_next_id;
221   fetch c_next_id into p_rec.performance_review_id;
222   close c_next_id;
223   --
224   hr_utility.set_location(' Leaving:'||l_proc, 10);
225 End pre_insert;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |-----------------------------< post_insert >------------------------------|
229 -- ----------------------------------------------------------------------------
230 -- {Start Of Comments}
231 --
232 -- Description:
233 --   This private procedure contains any processing which is required after the
234 --   insert dml.
235 --
236 -- Prerequisites:
237 --   This is an internal procedure which is called from the ins procedure.
238 --
239 -- In Parameters:
240 --   A Pl/Sql record structre.
241 --
242 -- Post Success:
243 --   Processing continues.
244 --
245 -- Post Failure:
246 --   If an error has occurred, an error message and exception will be raised
247 --   but not handled.
248 --
249 -- Developer Implementation Notes:
250 --   Any post-processing required after the insert dml is issued should be
251 --   coded within this procedure. It is important to note that any 3rd party
252 --   maintenance should be reviewed before placing in this procedure.
253 --
254 -- Access Status:
255 --   Internal Row Handler Use Only.
256 --
257 -- {End Of Comments}
258 -- ----------------------------------------------------------------------------
259 Procedure post_insert(p_rec in per_prv_shd.g_rec_type) is
260 --
261   l_proc  varchar2(72) := g_package||'post_insert';
262 --
263 Begin
264   hr_utility.set_location('Entering:'||l_proc, 5);
265 --
266   --
267   -- Start of API User Hook for post_insert.
268   --
269   begin
270     --
271     per_prv_rki.after_insert
272       (
273   p_performance_review_id         =>p_rec.performance_review_id
274  ,p_person_id                     =>p_rec.person_id
275  ,p_event_id                      =>p_rec.event_id
276  ,p_review_date                   =>p_rec.review_date
277  ,p_performance_rating            =>p_rec.performance_rating
278  ,p_next_perf_review_date         =>p_rec.next_perf_review_date
279  ,p_attribute_category            =>p_rec.attribute_category
280  ,p_attribute1                    =>p_rec.attribute1
281  ,p_attribute2                    =>p_rec.attribute2
282  ,p_attribute3                    =>p_rec.attribute3
283  ,p_attribute4                    =>p_rec.attribute4
284  ,p_attribute5                    =>p_rec.attribute5
285  ,p_attribute6                    =>p_rec.attribute6
286  ,p_attribute7                    =>p_rec.attribute7
287  ,p_attribute8                    =>p_rec.attribute8
288  ,p_attribute9                    =>p_rec.attribute9
289  ,p_attribute10                   =>p_rec.attribute10
290  ,p_attribute11                   =>p_rec.attribute11
291  ,p_attribute12                   =>p_rec.attribute12
292  ,p_attribute13                   =>p_rec.attribute13
293  ,p_attribute14                   =>p_rec.attribute14
294  ,p_attribute15                   =>p_rec.attribute15
295  ,p_attribute16                   =>p_rec.attribute16
296  ,p_attribute17                   =>p_rec.attribute17
297  ,p_attribute18                   =>p_rec.attribute18
298  ,p_attribute19                   =>p_rec.attribute19
299  ,p_attribute20                   =>p_rec.attribute20
300  ,p_attribute21                   =>p_rec.attribute21
301  ,p_attribute22                   =>p_rec.attribute22
302  ,p_attribute23                   =>p_rec.attribute23
303  ,p_attribute24                   =>p_rec.attribute24
304  ,p_attribute25                   =>p_rec.attribute25
305  ,p_attribute26                   =>p_rec.attribute26
306  ,p_attribute27                   =>p_rec.attribute27
307  ,p_attribute28                   =>p_rec.attribute28
308  ,p_attribute29                   =>p_rec.attribute29
309  ,p_attribute30                   =>p_rec.attribute30
310  ,p_object_version_number         =>p_rec.object_version_number
311       );
312     --
313   exception
314     --
315     when hr_api.cannot_find_prog_unit then
316       --
317       hr_api.cannot_find_prog_unit_error
318         (p_module_name => 'per_performance_reviews'
319         ,p_hook_type   => 'AI');
320       --
321   end;
322   --
323   -- End of API User Hook for post_insert.
324   --
325   --
326   hr_utility.set_location(' Leaving:'||l_proc, 10);
327 End post_insert;
328 --
329 -- ----------------------------------------------------------------------------
330 -- |---------------------------------< ins >----------------------------------|
331 -- ----------------------------------------------------------------------------
332 Procedure ins
333   (
334   p_rec        in out nocopy per_prv_shd.g_rec_type
335  ,p_next_review_date_warning out nocopy boolean
336  ,p_validate   in boolean
337   ) is
338 --
339   l_proc  varchar2(72) := g_package||'ins';
340 --
341 Begin
342   hr_utility.set_location('Entering:'||l_proc, 5);
343   --
344   -- Determine if the business process is to be validated.
345   --
346   If p_validate then
347     --
348     -- Issue the savepoint.
349     --
350     SAVEPOINT ins_per_prv;
351   End If;
352   --
353   -- Call the supporting insert validate operations
354   --
355   per_prv_bus.insert_validate(p_rec
356                              ,p_next_review_date_warning);
357   --
358   -- Call the supporting pre-insert operation
359   --
360   pre_insert(p_rec);
361   --
362   -- Insert the row
363   --
364   insert_dml(p_rec);
365   --
366   -- Call the supporting post-insert operation
367   --
368   post_insert(p_rec);
369 --
370   If p_validate then
371     Raise HR_Api.Validate_Enabled;
372   End If;
373   --
374   hr_utility.set_location(' Leaving:'||l_proc, 10);
375 Exception
376   When HR_Api.Validate_Enabled Then
377     --
378     -- As the Validate_Enabled exception has been raised
379     -- we must rollback to the savepoint
380     --
381     ROLLBACK TO ins_per_prv;
382 end ins;
383 --
384 -- ----------------------------------------------------------------------------
385 -- |---------------------------------< ins >----------------------------------|
386 -- ----------------------------------------------------------------------------
387 Procedure ins
388   (
389   p_performance_review_id        out nocopy number,
390   p_person_id                    in number,
391   p_event_id                     in number           default null,
392   p_review_date                  in date,
393   p_performance_rating           in varchar2         default null,
394   p_next_perf_review_date        in date             default null,
395   p_attribute_category           in varchar2         default null,
396   p_attribute1                   in varchar2         default null,
397   p_attribute2                   in varchar2         default null,
398   p_attribute3                   in varchar2         default null,
399   p_attribute4                   in varchar2         default null,
400   p_attribute5                   in varchar2         default null,
401   p_attribute6                   in varchar2         default null,
402   p_attribute7                   in varchar2         default null,
403   p_attribute8                   in varchar2         default null,
404   p_attribute9                   in varchar2         default null,
405   p_attribute10                  in varchar2         default null,
406   p_attribute11                  in varchar2         default null,
407   p_attribute12                  in varchar2         default null,
408   p_attribute13                  in varchar2         default null,
409   p_attribute14                  in varchar2         default null,
410   p_attribute15                  in varchar2         default null,
411   p_attribute16                  in varchar2         default null,
412   p_attribute17                  in varchar2         default null,
413   p_attribute18                  in varchar2         default null,
414   p_attribute19                  in varchar2         default null,
415   p_attribute20                  in varchar2         default null,
416   p_attribute21                  in varchar2         default null,
417   p_attribute22                  in varchar2         default null,
418   p_attribute23                  in varchar2         default null,
419   p_attribute24                  in varchar2         default null,
420   p_attribute25                  in varchar2         default null,
421   p_attribute26                  in varchar2         default null,
422   p_attribute27                  in varchar2         default null,
423   p_attribute28                  in varchar2         default null,
424   p_attribute29                  in varchar2         default null,
425   p_attribute30                  in varchar2         default null,
426   p_object_version_number        out nocopy number,
427   p_validate                     in boolean          default false,
428   p_next_review_date_warning     out nocopy boolean
429   ) is
430 --
431   l_rec	  per_prv_shd.g_rec_type;
432   l_proc  varchar2(72) := g_package||'ins';
433 --
434 Begin
435   hr_utility.set_location('Entering:'||l_proc, 5);
436   --
437   -- Call conversion function to turn arguments into the
438   -- p_rec structure.
439   --
440   l_rec :=
441   per_prv_shd.convert_args
442   (
443   null,
444   p_person_id,
445   p_event_id,
446   p_review_date,
447   p_performance_rating,
448   p_next_perf_review_date,
449   p_attribute_category,
450   p_attribute1,
451   p_attribute2,
452   p_attribute3,
453   p_attribute4,
454   p_attribute5,
455   p_attribute6,
456   p_attribute7,
457   p_attribute8,
458   p_attribute9,
459   p_attribute10,
460   p_attribute11,
461   p_attribute12,
462   p_attribute13,
463   p_attribute14,
464   p_attribute15,
465   p_attribute16,
466   p_attribute17,
467   p_attribute18,
468   p_attribute19,
469   p_attribute20,
470   p_attribute21,
471   p_attribute22,
472   p_attribute23,
473   p_attribute24,
474   p_attribute25,
475   p_attribute26,
476   p_attribute27,
477   p_attribute28,
478   p_attribute29,
479   p_attribute30,
480   null
481   );
482   --
483   -- Having converted the arguments into the per_prv_rec
484   -- plsql record structure we call the corresponding record business process.
485   --
486   ins(l_rec
487      ,p_next_review_date_warning
488      ,p_validate);
489   --
490   -- As the primary key argument(s)
491   -- are specified as an OUT's we must set these values.
492   --
493   p_performance_review_id := l_rec.performance_review_id;
494   p_object_version_number := l_rec.object_version_number;
495   --
496   hr_utility.set_location(' Leaving:'||l_proc, 10);
497 End ins;
498 --
499 end per_prv_ins;