DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PHN_INS

Source


1 Package Body per_phn_ins as
2 /* $Header: pephnrhi.pkb 120.3 2010/05/18 12:11:28 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_phn_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_phone_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_phone_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   per_phn_ins.g_phone_id_i := p_phone_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 -- ----------------------------------------------------------------------------
31 -- |------------------------------< insert_dml >------------------------------|
32 -- ----------------------------------------------------------------------------
33 -- {Start Of Comments}
34 --
35 -- Description:
36 --   This procedure controls the actual dml insert logic. The processing of
37 --   this procedure are as follows:
38 --   1) Initialise the object_version_number to 1 if the object_version_number
39 --      is defined as an attribute for this entity.
40 --   2) To insert the row into the schema.
41 --   3) To trap any constraint violations that may have occurred.
42 --   4) To raise any other errors.
43 --
44 -- Pre Conditions:
45 --   This is an internal private procedure which must be called from the ins
46 --   procedure and must have all mandatory attributes set (except the
47 --   object_version_number which is initialised within this procedure).
48 --
49 -- In Parameters:
50 --   A Pl/Sql record structre.
51 --
52 -- Post Success:
53 --   The specified row will be inserted into the schema.
54 --
55 -- Post Failure:
56 --   If a check, unique or parent integrity constraint violation is raised the
57 --   constraint_error procedure will be called.
58 --
59 -- Developer Implementation Notes:
60 --   None.
61 --
62 -- Access Status:
63 --   Internal Table Handler Use Only.
64 --
65 -- {End Of Comments}
66 -- ----------------------------------------------------------------------------
67 Procedure insert_dml(p_rec in out nocopy per_phn_shd.g_rec_type) is
68 --
69   l_proc  varchar2(72) := g_package||'insert_dml';
70 --
71 Begin
72   hr_utility.set_location('Entering:'||l_proc, 5);
73   p_rec.object_version_number := 1;  -- Initialise the object version
74   --
75   -- Insert the row into: per_phones
76   --
77   insert into per_phones
78   (	phone_id,
79 	date_from,
80 	date_to,
81 	phone_type,
82 	phone_number,
83 	parent_id,
84 	parent_table,
85 	attribute_category,
86 	attribute1,
87 	attribute2,
88 	attribute3,
89 	attribute4,
90 	attribute5,
91 	attribute6,
92 	attribute7,
93 	attribute8,
94 	attribute9,
95 	attribute10,
96 	attribute11,
97 	attribute12,
98 	attribute13,
99 	attribute14,
100 	attribute15,
101 	attribute16,
102 	attribute17,
103 	attribute18,
104 	attribute19,
105 	attribute20,
106 	attribute21,
107 	attribute22,
108 	attribute23,
109 	attribute24,
110 	attribute25,
111 	attribute26,
112 	attribute27,
113 	attribute28,
114 	attribute29,
115 	attribute30,
116         party_id,               -- HR/TCA merge
117 	validity,
118 	object_version_number
119   )
120   Values
121   (	p_rec.phone_id,
122 	p_rec.date_from,
123 	p_rec.date_to,
124 	p_rec.phone_type,
125 	p_rec.phone_number,
126 	p_rec.parent_id,
127 	p_rec.parent_table,
128 	p_rec.attribute_category,
129 	p_rec.attribute1,
130 	p_rec.attribute2,
131 	p_rec.attribute3,
132 	p_rec.attribute4,
133 	p_rec.attribute5,
134 	p_rec.attribute6,
135 	p_rec.attribute7,
136 	p_rec.attribute8,
137 	p_rec.attribute9,
138 	p_rec.attribute10,
139 	p_rec.attribute11,
140 	p_rec.attribute12,
141 	p_rec.attribute13,
142 	p_rec.attribute14,
143 	p_rec.attribute15,
144 	p_rec.attribute16,
145 	p_rec.attribute17,
146 	p_rec.attribute18,
147 	p_rec.attribute19,
148 	p_rec.attribute20,
149 	p_rec.attribute21,
150 	p_rec.attribute22,
151 	p_rec.attribute23,
152 	p_rec.attribute24,
153 	p_rec.attribute25,
154 	p_rec.attribute26,
155 	p_rec.attribute27,
156 	p_rec.attribute28,
157 	p_rec.attribute29,
158 	p_rec.attribute30,
159 	p_rec.party_id,         -- HR/TCA merge
160 	p_rec.validity,
161 	p_rec.object_version_number
162   );
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_phn_shd.constraint_error
169       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
170   When hr_api.parent_integrity_violated Then
171     -- Parent integrity has been violated
172     per_phn_shd.constraint_error
173       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
174   When hr_api.unique_integrity_violated Then
175     -- Unique integrity has been violated
176     per_phn_shd.constraint_error
177       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
178   When Others Then
179   Raise;
180 End insert_dml;
181 --
182 -- ----------------------------------------------------------------------------
183 -- |------------------------------< pre_insert >------------------------------|
184 -- ----------------------------------------------------------------------------
185 -- {Start Of Comments}
186 --
187 -- Description:
188 --   This private procedure contains any processing which is required before
189 --   the insert dml. Presently, if the entity has a corresponding primary
190 --   key which is maintained by an associating sequence, the primary key for
191 --   the entity will be populated with the next sequence value in
192 --   preparation for the insert dml.
193 --
194 -- Pre Conditions:
195 --   This is an internal procedure which is called from the ins procedure.
196 --
197 -- In Parameters:
198 --   A Pl/Sql record structre.
199 --
200 -- Post Success:
201 --   Processing continues.
202 --
203 -- Post Failure:
204 --   If an error has occurred, an error message and exception will be raised
205 --   but not handled.
206 --
207 -- Developer Implementation Notes:
208 --   Any pre-processing required before the insert dml is issued should be
209 --   coded within this procedure. As stated above, a good example is the
210 --   generation of a primary key number via a corresponding sequence.
211 --   It is important to note that any 3rd party maintenance should be reviewed
212 --   before placing in this procedure.
213 --
214 -- Access Status:
215 --   Internal Table Handler Use Only.
216 --
217 -- {End Of Comments}
218 -- ----------------------------------------------------------------------------
219 Procedure pre_insert(p_rec  in out nocopy per_phn_shd.g_rec_type) is
220 --
221   l_proc  varchar2(72) := g_package||'pre_insert';
222   l_exists varchar2(1);
223 --
224   Cursor C_Sel1 is select per_phones_s.nextval from sys.dual;
225 --
226   Cursor C_Sel2 is
227          select null
228                 from per_phones
229                 where phone_id = per_phn_ins.g_phone_id_i;
230 --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 5);
233   --
234   if per_phn_ins.g_phone_id_i is not null then
235     --
236     -- Verify registered primary key values not already in use
237     --
238     Open C_Sel2;
239     Fetch C_Sel2 into l_exists;
240     If C_Sel2%found then
241       Close C_Sel2;
242       --
243       -- The primary key values are already in use.
244       --
245       fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
246       fnd_message.set_token('TABLE_NAME','per_phones');
247       fnd_message.raise_error;
248     end if;
249     Close C_Sel2;
250     --
251     -- Use registered key values and clear globals
252     --
253     p_rec.phone_id :=
254       per_phn_ins.g_phone_id_i;
255     per_phn_ins.g_phone_id_i := null;
256   else
257     --
258     -- Select the next sequence number
259     --
260     Open C_Sel1;
261     Fetch C_Sel1 Into p_rec.phone_id;
262     Close C_Sel1;
263     --
264   end if;
265   hr_utility.set_location(' Leaving:'||l_proc, 10);
266 End pre_insert;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |-----------------------------< post_insert >------------------------------|
270 -- ----------------------------------------------------------------------------
271 -- {Start Of Comments}
272 --
273 -- Description:
274 --   This private procedure contains any processing which is required after the
275 --   insert dml.
276 --
277 -- Pre Conditions:
278 --   This is an internal procedure which is called from the ins procedure.
279 --
280 -- In Parameters:
281 --   A Pl/Sql record structre.
282 --
283 -- Post Success:
284 --   Processing continues.
285 --
286 -- Post Failure:
287 --   If an error has occurred, an error message and exception will be raised
288 --   but not handled.
289 --
290 -- Developer Implementation Notes:
291 --   Any post-processing required after the insert dml is issued should be
292 --   coded within this procedure. It is important to note that any 3rd party
293 --   maintenance should be reviewed before placing in this procedure.
294 --
295 -- Access Status:
296 --   Internal Table Handler Use Only.
297 --
298 -- {End Of Comments}
299 -- ----------------------------------------------------------------------------
300 Procedure post_insert(p_rec in per_phn_shd.g_rec_type,
301                       p_effective_date in date ) is
302 --
303   l_proc  varchar2(72) := g_package||'post_insert';
304 --
305 Begin
306   hr_utility.set_location('Entering:'||l_proc, 5);
307   --
308   --
309   -- Start of API User Hook for post_insert.
310   begin
311     per_phn_rki.after_insert
312 	 (
313 	   p_phone_id		=> p_rec.phone_id
314 	  ,p_date_from           => p_rec.date_from
315 	  ,p_date_to             => p_rec.date_to
316 	  ,p_phone_type          => p_rec.phone_type
317 	  ,p_phone_number        => p_rec.phone_number
318 	  ,p_parent_id           => p_rec.parent_id
319 	  ,p_parent_table        => p_rec.parent_table
320 	  ,p_attribute_category  => p_rec.attribute_category
321 	  ,p_attribute1          => p_rec.attribute1
322 	  ,p_attribute2          => p_rec.attribute2
323 	  ,p_attribute3          => p_rec.attribute3
324 	  ,p_attribute4          => p_rec.attribute4
325 	  ,p_attribute5          => p_rec.attribute5
326 	  ,p_attribute6          => p_rec.attribute6
327 	  ,p_attribute7          => p_rec.attribute7
328 	  ,p_attribute8          => p_rec.attribute8
329 	  ,p_attribute9          => p_rec.attribute9
330 	  ,p_attribute10         => p_rec.attribute10
331 	  ,p_attribute11         => p_rec.attribute11
332 	  ,p_attribute12         => p_rec.attribute12
333 	  ,p_attribute13         => p_rec.attribute13
334 	  ,p_attribute14         => p_rec.attribute14
335 	  ,p_attribute15         => p_rec.attribute15
336 	  ,p_attribute16         => p_rec.attribute16
337 	  ,p_attribute17         => p_rec.attribute17
338 	  ,p_attribute18         => p_rec.attribute18
339 	  ,p_attribute19         => p_rec.attribute19
340 	  ,p_attribute20         => p_rec.attribute20
341 	  ,p_attribute21         => p_rec.attribute21
342 	  ,p_attribute22         => p_rec.attribute22
343 	  ,p_attribute23         => p_rec.attribute23
344 	  ,p_attribute24         => p_rec.attribute24
345 	  ,p_attribute25         => p_rec.attribute25
346 	  ,p_attribute26         => p_rec.attribute26
347 	  ,p_attribute27         => p_rec.attribute27
348 	  ,p_attribute28         => p_rec.attribute28
349 	  ,p_attribute29         => p_rec.attribute29
350 	  ,p_attribute30         => p_rec.attribute30
351 	  ,p_party_id            => p_rec.party_id   -- HR/TCA merge
352 	  ,p_validity            => p_rec.validity
353 	  ,p_object_version_number  => p_rec.object_version_number
354 	  ,p_effective_date         => p_effective_date
355 	  );
356   exception
357     when hr_api.cannot_find_prog_unit then
358       hr_api.cannot_find_prog_unit_error
359         (p_module_name => 'PER_PHONES'
360         ,p_hook_type   => 'AI'
361         );
362   end;
363   --
364   -- End of API User Hook for post_insert.
365   --
366   hr_utility.set_location(' Leaving:'||l_proc, 10);
367 End post_insert;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |---------------------------------< ins >----------------------------------|
371 -- ----------------------------------------------------------------------------
372 Procedure ins
373   (
374   p_rec        in out nocopy per_phn_shd.g_rec_type,
375   p_validate   in     boolean default false,
376   p_effective_date in date
377   ) is
378 --
379   l_proc  varchar2(72) := g_package||'ins';
380 --
381 Begin
382   hr_utility.set_location('Entering:'||l_proc, 5);
383   --
384   -- Determine if the business process is to be validated.
385   --
386   If p_validate then
387     --
388     -- Issue the savepoint.
389     --
390     SAVEPOINT ins_per_phn;
391   End If;
392   --
393   -- Call the supporting insert validate operations
394   --
395   per_phn_bus.insert_validate(p_rec
396                               ,p_effective_date
397                               );
398   --
399   -- Call to raise any errors on multi-message list
400   --
401   hr_multi_message.end_validation_set;
402   --
403   -- Call the supporting pre-insert operation
404   --
405   pre_insert(p_rec);
406   --
407   -- Insert the row
408   --
409   insert_dml(p_rec);
410   --
411   -- Call the supporting post-insert operation
412   --
413   post_insert(p_rec, p_effective_date);
414   --
415   -- Call to raise any errors on multi-message list
416   --
417   hr_multi_message.end_validation_set;
418   --
419   -- If we are validating then raise the Validate_Enabled exception
420   --
421   If p_validate then
422     Raise HR_Api.Validate_Enabled;
423   End If;
424   --
425   hr_utility.set_location(' Leaving:'||l_proc, 10);
426 Exception
427   When HR_Api.Validate_Enabled Then
428     --
429     -- As the Validate_Enabled exception has been raised
430     -- we must rollback to the savepoint
431     --
432     ROLLBACK TO ins_per_phn;
433 end ins;
434 --
435 -- ----------------------------------------------------------------------------
436 -- |---------------------------------< ins >----------------------------------|
437 -- ----------------------------------------------------------------------------
438 Procedure ins
439   (
440   p_phone_id                     out nocopy number,
441   p_date_from                    in date,
442   p_date_to                      in date             default null,
443   p_phone_type                   in varchar2,
444   p_phone_number                 in varchar2,
445   p_parent_id                    in number           default null, -- HR/TCA merge
446   p_parent_table                 in varchar2         default null, -- HR/TCA merge
447   p_attribute_category           in varchar2         default null,
448   p_attribute1                   in varchar2         default null,
449   p_attribute2                   in varchar2         default null,
450   p_attribute3                   in varchar2         default null,
451   p_attribute4                   in varchar2         default null,
452   p_attribute5                   in varchar2         default null,
453   p_attribute6                   in varchar2         default null,
454   p_attribute7                   in varchar2         default null,
455   p_attribute8                   in varchar2         default null,
456   p_attribute9                   in varchar2         default null,
457   p_attribute10                  in varchar2         default null,
458   p_attribute11                  in varchar2         default null,
459   p_attribute12                  in varchar2         default null,
460   p_attribute13                  in varchar2         default null,
461   p_attribute14                  in varchar2         default null,
462   p_attribute15                  in varchar2         default null,
463   p_attribute16                  in varchar2         default null,
464   p_attribute17                  in varchar2         default null,
465   p_attribute18                  in varchar2         default null,
466   p_attribute19                  in varchar2         default null,
467   p_attribute20                  in varchar2         default null,
468   p_attribute21                  in varchar2         default null,
469   p_attribute22                  in varchar2         default null,
470   p_attribute23                  in varchar2         default null,
471   p_attribute24                  in varchar2         default null,
472   p_attribute25                  in varchar2         default null,
473   p_attribute26                  in varchar2         default null,
474   p_attribute27                  in varchar2         default null,
475   p_attribute28                  in varchar2         default null,
476   p_attribute29                  in varchar2         default null,
477   p_attribute30                  in varchar2         default null,
478   p_party_id                     in number           default null, -- HR/TCA merge
479   p_validity                     in varchar2         default null,
480   p_object_version_number        out nocopy number,
481   p_validate                     in boolean   default false,
482   p_effective_date               in date
483   ) is
484 --
485   l_rec	  per_phn_shd.g_rec_type;
486   l_proc  varchar2(72) := g_package||'ins';
487 --
488 Begin
489   hr_utility.set_location('Entering:'||l_proc, 5);
490   --
491   -- Call conversion function to turn arguments into the
492   -- p_rec structure.
493   --
494   l_rec :=
495   per_phn_shd.convert_args
496   (
497   null,
498   p_date_from,
499   p_date_to,
500   p_phone_type,
501   p_phone_number,
502   p_parent_id,
503   p_parent_table,
504   p_attribute_category,
505   p_attribute1,
506   p_attribute2,
507   p_attribute3,
508   p_attribute4,
509   p_attribute5,
510   p_attribute6,
511   p_attribute7,
512   p_attribute8,
513   p_attribute9,
514   p_attribute10,
515   p_attribute11,
516   p_attribute12,
517   p_attribute13,
518   p_attribute14,
519   p_attribute15,
520   p_attribute16,
521   p_attribute17,
522   p_attribute18,
523   p_attribute19,
524   p_attribute20,
525   p_attribute21,
526   p_attribute22,
527   p_attribute23,
528   p_attribute24,
529   p_attribute25,
530   p_attribute26,
531   p_attribute27,
532   p_attribute28,
533   p_attribute29,
534   p_attribute30,
535   p_party_id, -- HR/TCA merge
536   p_validity,
537   null
538   );
539   --
540   -- Having converted the arguments into the per_phn_rec
541   -- plsql record structure we call the corresponding record business process.
542   --
543   ins(l_rec, p_validate, p_effective_date);
544   --
545   -- As the primary key argument(s)
546   -- are specified as an OUT's we must set these values.
547   --
548   p_phone_id := l_rec.phone_id;
549   p_object_version_number := l_rec.object_version_number;
550   --
551   hr_utility.set_location(' Leaving:'||l_proc, 10);
552 End ins;
553 --
554 end per_phn_ins;