DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RTL_INS

Source


1 Package Body per_rtl_ins as
2 /* $Header: pertlrhi.pkb 120.0 2005/05/31 19:57:25 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_rtl_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 insert the row into the schema.
21 --   3) To trap any constraint violations that may have occurred.
22 --   4) To raise any other errors.
23 --
24 -- Pre Conditions:
25 --   This is an internal private procedure which must be called from the ins
26 --   procedure and must have all mandatory attributes set (except the
27 --   object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   None.
41 --
42 -- Access Status:
43 --   Internal Table Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out nocopy per_rtl_shd.g_rec_type) is
48 --
49   l_proc  varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52   hr_utility.set_location('Entering:'||l_proc, 5);
53   p_rec.object_version_number := 1;  -- Initialise the object version
54   --
55   -- Insert the row into: per_rating_levels
56   --
57   insert into per_rating_levels
58   (	rating_level_id,
59 	business_group_id,
60 	step_value,
61 	rating_scale_id,
62 	name,
63 	object_version_number,
64         behavioural_indicator,
65         competence_id,
66 	attribute_category,
67 	attribute1,
68 	attribute2,
69 	attribute3,
70 	attribute4,
71 	attribute5,
72 	attribute6,
73 	attribute7,
74 	attribute8,
75 	attribute9,
76 	attribute10,
77 	attribute11,
78 	attribute12,
79 	attribute13,
80 	attribute14,
81 	attribute15,
82 	attribute16,
83 	attribute17,
84 	attribute18,
85 	attribute19,
86 	attribute20
87   )
88   Values
89   (	p_rec.rating_level_id,
90 	p_rec.business_group_id,
91 	p_rec.step_value,
92 	p_rec.rating_scale_id,
93 	p_rec.name,
94 	p_rec.object_version_number,
95         p_rec.behavioural_indicator,
96         p_rec.competence_id,
97 	p_rec.attribute_category,
98 	p_rec.attribute1,
99 	p_rec.attribute2,
100 	p_rec.attribute3,
101 	p_rec.attribute4,
102 	p_rec.attribute5,
103 	p_rec.attribute6,
104 	p_rec.attribute7,
105 	p_rec.attribute8,
106 	p_rec.attribute9,
107 	p_rec.attribute10,
108 	p_rec.attribute11,
109 	p_rec.attribute12,
110 	p_rec.attribute13,
111 	p_rec.attribute14,
112 	p_rec.attribute15,
113 	p_rec.attribute16,
114 	p_rec.attribute17,
115 	p_rec.attribute18,
116 	p_rec.attribute19,
117 	p_rec.attribute20
118   );
119   --
120   hr_utility.set_location(' Leaving:'||l_proc, 10);
121 Exception
122   When hr_api.check_integrity_violated Then
123     -- A check constraint has been violated
124     per_rtl_shd.constraint_error
125       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126   When hr_api.parent_integrity_violated Then
127     -- Parent integrity has been violated
128     per_rtl_shd.constraint_error
129       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
130   When hr_api.unique_integrity_violated Then
131     -- Unique integrity has been violated
132     per_rtl_shd.constraint_error
133       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
134   When Others Then
135     Raise;
136 End insert_dml;
137 --
138 -- ----------------------------------------------------------------------------
139 -- |------------------------------< pre_insert >------------------------------|
140 -- ----------------------------------------------------------------------------
141 -- {Start Of Comments}
142 --
143 -- Description:
144 --   This private procedure contains any processing which is required before
145 --   the insert dml. Presently, if the entity has a corresponding primary
146 --   key which is maintained by an associating sequence, the primary key for
147 --   the entity will be populated with the next sequence value in
148 --   preparation for the insert dml.
149 --
150 -- Pre Conditions:
151 --   This is an internal procedure which is called from the ins procedure.
152 --
153 -- In Parameters:
154 --   A Pl/Sql record structre.
155 --
156 -- Post Success:
157 --   Processing continues.
158 --
159 -- Post Failure:
160 --   If an error has occurred, an error message and exception will be raised
161 --   but not handled.
162 --
163 -- Developer Implementation Notes:
164 --   Any pre-processing required before the insert dml is issued should be
165 --   coded within this procedure. As stated above, a good example is the
166 --   generation of a primary key number via a corresponding sequence.
167 --   It is important to note that any 3rd party maintenance should be reviewed
168 --   before placing in this procedure.
169 --
170 -- Access Status:
171 --   Internal Table Handler Use Only.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure pre_insert(p_rec  in out nocopy per_rtl_shd.g_rec_type) is
176 --
177   l_proc  varchar2(72) := g_package||'pre_insert';
178 --
179   Cursor C_Sel1 is select per_rating_levels_s.nextval from sys.dual;
180 --
181 Begin
182   hr_utility.set_location('Entering:'||l_proc, 5);
183   --
184   --
185   -- Select the next sequence number
186   --
187   Open C_Sel1;
188   Fetch C_Sel1 Into p_rec.rating_level_id;
189   Close C_Sel1;
190   --
191   hr_utility.set_location(' Leaving:'||l_proc, 10);
192 End pre_insert;
193 --
194 -- ----------------------------------------------------------------------------
195 -- |-----------------------------< post_insert >------------------------------|
196 -- ----------------------------------------------------------------------------
197 -- {Start Of Comments}
198 --
199 -- Description:
200 --   This private procedure contains any processing which is required after the
201 --   insert dml.
202 --
203 -- Pre Conditions:
204 --   This is an internal procedure which is called from the ins procedure.
205 --
206 -- In Parameters:
207 --   A Pl/Sql record structre.
208 --
209 -- Post Success:
210 --   Processing continues.
211 --
212 -- Post Failure:
213 --   If an error has occurred, an error message and exception will be raised
214 --   but not handled.
215 --
216 -- Developer Implementation Notes:
217 --   Any post-processing required after the insert dml is issued should be
218 --   coded within this procedure. It is important to note that any 3rd party
219 --   maintenance should be reviewed before placing in this procedure.
220 --
221 -- Access Status:
222 --   Internal Table Handler Use Only.
223 --
224 -- {End Of Comments}
225 -- ----------------------------------------------------------------------------
226 Procedure post_insert(p_rec in per_rtl_shd.g_rec_type) is
227 --
228   l_proc  varchar2(72) := g_package||'post_insert';
229 --
230 Begin
231   hr_utility.set_location('Entering:'||l_proc, 5);
232   --
233   -- This is a hook point and the user hook for post_insert is called here.
234   --
235   begin
236      per_rtl_rki.after_insert	(
237       p_rating_level_id        => p_rec.rating_level_id       ,
238       p_business_group_id      => p_rec.business_group_id     ,
239       p_object_version_number  => p_rec.object_version_number ,
240       p_step_value             => p_rec.step_value            ,
241       p_name                   => p_rec.name                  ,
242       p_rating_scale_id        => p_rec.rating_scale_id       ,
243       p_competence_id          => p_rec.competence_id         ,
244       p_behavioural_indicator  => p_rec.behavioural_indicator ,
245       p_attribute_category     => p_rec.attribute_category    ,
246       p_attribute1             => p_rec.attribute1   ,
247       p_attribute2             => p_rec.attribute2   ,
248       p_attribute3             => p_rec.attribute3   ,
249       p_attribute4             => p_rec.attribute4   ,
250       p_attribute5             => p_rec.attribute5   ,
251       p_attribute6             => p_rec.attribute6   ,
252       p_attribute7             => p_rec.attribute7   ,
253       p_attribute8             => p_rec.attribute8   ,
254       p_attribute9             => p_rec.attribute9   ,
255       p_attribute10            => p_rec.attribute10  ,
256       p_attribute11            => p_rec.attribute11  ,
257       p_attribute12            => p_rec.attribute12  ,
258       p_attribute13            => p_rec.attribute13  ,
259       p_attribute14            => p_rec.attribute14  ,
260       p_attribute15            => p_rec.attribute15  ,
261       p_attribute16            => p_rec.attribute16  ,
262       p_attribute17            => p_rec.attribute17  ,
263       p_attribute18            => p_rec.attribute18  ,
264       p_attribute19            => p_rec.attribute19  ,
265       p_attribute20            => p_rec.attribute20  );
266 
267 exception
268         when hr_api.cannot_find_prog_unit then
269              hr_api.cannot_find_prog_unit_error
270 		 (	 p_module_name => 'PER_RATING_LEVELS'
271 			,p_hook_type   => 'AI'
272 	        );
273   end;
274   -- End of API User Hook for post_insert.
275   --
276   hr_utility.set_location(' Leaving:'||l_proc, 10);
277 End post_insert;
278 --
279 -- ----------------------------------------------------------------------------
280 -- |---------------------------------< ins >----------------------------------|
281 -- ----------------------------------------------------------------------------
282 Procedure ins
283   (
284   p_rec        in out nocopy per_rtl_shd.g_rec_type,
285   p_effective_date      in date             default null,
286   p_validate   in     boolean default false
287   ) is
288 --
289   l_proc  varchar2(72) := g_package||'ins';
290 --
291 Begin
292   hr_utility.set_location('Entering:'||l_proc, 5);
293   --
294   -- Determine if the business process is to be validated.
295   --
296   If p_validate then
297     --
298     -- Issue the savepoint.
299     --
300     SAVEPOINT ins_per_rtl;
301   End If;
302   --
303   -- Call the supporting insert validate operations
304   --
305   per_rtl_bus.insert_validate(p_rec,p_effective_date);
306   --
307   -- Call the supporting pre-insert operation
308   --
312   --
309   pre_insert(p_rec);
310   --
311   -- Insert the row
313   insert_dml(p_rec);
314   --
315   -- Call the supporting post-insert operation
316   --
317   post_insert(p_rec);
318   --
319   -- If we are validating then raise the Validate_Enabled exception
320   --
321   If p_validate then
322     Raise HR_Api.Validate_Enabled;
323   End If;
324   --
325   hr_utility.set_location(' Leaving:'||l_proc, 10);
326 Exception
327   When HR_Api.Validate_Enabled Then
328     --
329     -- As the Validate_Enabled exception has been raised
330     -- we must rollback to the savepoint
331     --
332     ROLLBACK TO ins_per_rtl;
333 end ins;
334 --
335 -- ----------------------------------------------------------------------------
336 -- |---------------------------------< ins >----------------------------------|
337 -- ----------------------------------------------------------------------------
338 Procedure ins
339   (
340   p_rating_level_id              out nocopy number,
341   p_business_group_id            in number           default null,
342   p_step_value                   in number,
343   p_rating_scale_id              in number           default null,
344   p_name                         in varchar2,
345   p_object_version_number        out nocopy number,
346   p_behavioural_indicator        in varchar2         default null,
347   p_competence_id                in number           default null,
348   p_attribute_category           in varchar2         default null,
349   p_attribute1                   in varchar2         default null,
350   p_attribute2                   in varchar2         default null,
351   p_attribute3                   in varchar2         default null,
352   p_attribute4                   in varchar2         default null,
353   p_attribute5                   in varchar2         default null,
354   p_attribute6                   in varchar2         default null,
355   p_attribute7                   in varchar2         default null,
356   p_attribute8                   in varchar2         default null,
357   p_attribute9                   in varchar2         default null,
358   p_attribute10                  in varchar2         default null,
359   p_attribute11                  in varchar2         default null,
360   p_attribute12                  in varchar2         default null,
361   p_attribute13                  in varchar2         default null,
362   p_attribute14                  in varchar2         default null,
363   p_attribute15                  in varchar2         default null,
364   p_attribute16                  in varchar2         default null,
365   p_attribute17                  in varchar2         default null,
366   p_attribute18                  in varchar2         default null,
367   p_attribute19                  in varchar2         default null,
368   p_attribute20                  in varchar2         default null,
369   p_effective_date               in date             ,
370   p_validate                     in boolean   default false
371   ) is
372 --
373   l_rec	  per_rtl_shd.g_rec_type;
374   l_proc  varchar2(72) := g_package||'ins';
375 --
376 Begin
377   hr_utility.set_location('Entering:'||l_proc, 5);
378   --
379   -- Call conversion function to turn arguments into the
380   -- p_rec structure.
381   --
382   l_rec :=
383   per_rtl_shd.convert_args
384   (
385   null,
386   p_business_group_id,
387   p_step_value,
388   p_rating_scale_id,
389   p_name,
390   null,
391   p_behavioural_indicator,
392   p_competence_id,
393   p_attribute_category,
394   p_attribute1,
395   p_attribute2,
396   p_attribute3,
397   p_attribute4,
398   p_attribute5,
399   p_attribute6,
400   p_attribute7,
401   p_attribute8,
402   p_attribute9,
403   p_attribute10,
404   p_attribute11,
405   p_attribute12,
406   p_attribute13,
407   p_attribute14,
408   p_attribute15,
409   p_attribute16,
410   p_attribute17,
411   p_attribute18,
412   p_attribute19,
413   p_attribute20
414   );
415   --
416   -- Having converted the arguments into the per_rtl_rec
417   -- plsql record structure we call the corresponding record business process.
418   --
419   ins(l_rec,p_effective_date,p_validate);
420   --
421   -- As the primary key argument(s)
422   -- are specified as an OUT's we must set these values.
423   --
424   p_rating_level_id := l_rec.rating_level_id;
425   p_object_version_number := l_rec.object_version_number;
426   --
427   hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End ins;
429 --
430 end per_rtl_ins;