DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_ASR_INS

Source


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