DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RSC_INS

Source


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