DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_EST_INS

Source


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