DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_KAD_INS

Source


1 Package Body per_kad_ins as
2 /* $Header: pekadrhi.pkb 120.1 2011/11/17 11:35:55 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_kad_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 functions of this
17 --   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 arguments set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Arguments:
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 --
48 -- Access Status:
45 -- Developer Implementation Notes:
46 --   None.
47 --
49 --   Internal Table Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_kad_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_kad_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: per_addresses
64   --
65   insert into per_addresses
66   (	address_id,
67 	business_group_id,
68 	person_id,
69 	date_from,
70 	primary_flag,
71 	style,
72 	address_line1,
73 	address_line2,
74 	address_line3,
75 	address_type,
76 	comments,
77 	country,
78 	date_to,
79 	postal_code,
80 	region_1,
81 	region_2,
82 	region_3,
83 	telephone_number_1,
84 	telephone_number_2,
85 	telephone_number_3,
86 	town_or_city,
87 	request_id,
88 	program_application_id,
89 	program_id,
90 	program_update_date,
91 	addr_attribute_category,
92 	addr_attribute1,
93 	addr_attribute2,
94 	addr_attribute3,
95 	addr_attribute4,
96 	addr_attribute5,
97 	addr_attribute6,
98 	addr_attribute7,
99 	addr_attribute8,
100 	addr_attribute9,
101 	addr_attribute10,
102 	addr_attribute11,
103 	addr_attribute12,
104 	addr_attribute13,
105 	addr_attribute14,
106 	addr_attribute15,
107 	addr_attribute16,
108 	addr_attribute17,
109 	addr_attribute18,
110 	addr_attribute19,
111 	addr_attribute20,
112 	object_version_number
113   )
114   Values
115   (	p_rec.address_id,
116 	p_rec.business_group_id,
117 	p_rec.person_id,
118 	p_rec.date_from,
119 	p_rec.primary_flag,
120 	p_rec.style,
121 	p_rec.address_line1,
122 	p_rec.address_line2,
123 	p_rec.address_line3,
124 	p_rec.address_type,
125 	p_rec.comments,
126 	p_rec.country,
127 	p_rec.date_to,
128 	p_rec.postal_code,
129 	p_rec.region_1,
130 	p_rec.region_2,
131 	p_rec.region_3,
132 	p_rec.telephone_number_1,
133 	p_rec.telephone_number_2,
134 	p_rec.telephone_number_3,
135 	p_rec.town_or_city,
136 	p_rec.request_id,
137 	p_rec.program_application_id,
138 	p_rec.program_id,
139 	p_rec.program_update_date,
140 	p_rec.addr_attribute_category,
141 	p_rec.addr_attribute1,
142 	p_rec.addr_attribute2,
143 	p_rec.addr_attribute3,
144 	p_rec.addr_attribute4,
145 	p_rec.addr_attribute5,
146 	p_rec.addr_attribute6,
147 	p_rec.addr_attribute7,
148 	p_rec.addr_attribute8,
149 	p_rec.addr_attribute9,
150 	p_rec.addr_attribute10,
151 	p_rec.addr_attribute11,
152 	p_rec.addr_attribute12,
153 	p_rec.addr_attribute13,
154 	p_rec.addr_attribute14,
155 	p_rec.addr_attribute15,
156 	p_rec.addr_attribute16,
157 	p_rec.addr_attribute17,
158 	p_rec.addr_attribute18,
159 	p_rec.addr_attribute19,
160 	p_rec.addr_attribute20,
161 	p_rec.object_version_number
162   );
163   --
164   per_kad_shd.g_api_dml := false;   -- Unset the api dml status
165   --
166   hr_utility.set_location(' Leaving:'||l_proc, 10);
167 Exception
168   When hr_api.check_integrity_violated Then
169     -- A check constraint has been violated
170     per_kad_shd.g_api_dml := false;   -- Unset the api dml status
171     per_kad_shd.constraint_error
172       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
173   When hr_api.parent_integrity_violated Then
174     -- Parent integrity has been violated
175     per_kad_shd.g_api_dml := false;   -- Unset the api dml status
176     per_kad_shd.constraint_error
177       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
178   When hr_api.unique_integrity_violated Then
179     -- Unique integrity has been violated
180     per_kad_shd.g_api_dml := false;   -- Unset the api dml status
181     per_kad_shd.constraint_error
182       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
183   When Others Then
184     per_kad_shd.g_api_dml := false;   -- Unset the api dml status
185     Raise;
186 End insert_dml;
187 --
188 -- ----------------------------------------------------------------------------
189 -- |------------------------------< pre_insert >------------------------------|
190 -- ----------------------------------------------------------------------------
191 -- {Start Of Comments}
192 --
193 -- Description:
194 --   This private procedure contains any processing which is required before
195 --   the insert dml. Presently, if the entity has a corresponding primary
196 --   key which is maintained by an associating sequence, the primary key for
197 --   the entity will be populated with the next sequence value in
198 --   preparation for the insert dml.
199 --
200 -- Pre Conditions:
201 --   This is an internal procedure which is called from the ins procedure.
202 --
203 -- In Arguments:
204 --   A Pl/Sql record structre.
205 --
206 -- Post Success:
207 --   Processing continues.
208 --
209 -- Post Failure:
210 --   If an error has occurred, an error message and exception will be raised
211 --   but not handled.
212 --
216 --   generation of a primary key number via a corresponding sequence.
213 -- Developer Implementation Notes:
214 --   Any pre-processing required before the insert dml is issued should be
215 --   coded within this procedure. As stated above, a good example is the
217 --   It is important to note that any 3rd party maintenance should be reviewed
218 --   before placing in this procedure.
219 --
220 -- Access Status:
221 --   Internal Table Handler Use Only.
222 --
223 -- {End Of Comments}
224 -- ----------------------------------------------------------------------------
225 Procedure pre_insert(p_rec  in out nocopy per_kad_shd.g_rec_type) is
226 --
227   l_proc  varchar2(72) := g_package||'pre_insert';
228 --
229   Cursor C_Sel1 is select per_addresses_s.nextval from sys.dual;
230 --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 5);
233   --
234   --
235   -- Select the next sequence number
236   --
237   Open C_Sel1;
238   Fetch C_Sel1 Into p_rec.address_id;
239   Close C_Sel1;
240   --
241   hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End pre_insert;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |-----------------------------< post_insert >------------------------------|
246 -- ----------------------------------------------------------------------------
247 -- {Start Of Comments}
248 --
249 -- Description:
250 --   This private procedure contains any processing which is required after the
251 --   insert dml.
252 --
253 -- Pre Conditions:
254 --   This is an internal procedure which is called from the ins procedure.
255 --
256 -- In Arguments:
257 --   A Pl/Sql record structre.
258 --
259 -- Post Success:
260 --   Processing continues.
261 --
262 -- Post Failure:
263 --   If an error has occurred, an error message and exception will be raised
264 --   but not handled.
265 --
266 -- Developer Implementation Notes:
267 --   Any post-processing required after the insert dml is issued should be
268 --   coded within this procedure. It is important to note that any 3rd party
269 --   maintenance should be reviewed before placing in this procedure.
270 --
271 -- Access Status:
272 --   Internal Table Handler Use Only.
273 --
274 -- {End Of Comments}
275 -- ----------------------------------------------------------------------------
276 Procedure post_insert(p_rec            in per_kad_shd.g_rec_type,
277                       p_effective_date in date) is
278   --
279   l_proc  varchar2(72) := g_package||'post_insert';
280   --
281   -- Fix for WWBUG 1408379
282   --
283   l_old               ben_add_ler.g_add_ler_rec;
284   l_new               ben_add_ler.g_add_ler_rec;
285   --
286   -- End of Fix for WWBUG 1408379
287   --
288 Begin
289   hr_utility.set_location('Entering:'||l_proc, 5);
290   --
291   -- Fix for WWBUG 1408379
292   --
293   l_new.person_id := p_rec.person_id;
294   l_new.business_group_id := p_rec.business_group_id;
295   l_new.date_from := p_rec.date_from;
296   l_new.date_to := p_rec.date_to;
297   l_new.primary_flag := p_rec.primary_flag;
298   l_new.postal_code := p_rec.postal_code;
299   l_new.region_2 := p_rec.region_2;
300   l_new.address_type := p_rec.address_type;
301   l_new.address_id := p_rec.address_id;
302   --
303   ben_add_ler.ler_chk(p_old            => l_old,
304                       p_new            => l_new,
305                       p_effective_date => l_new.date_from);
306   --
307   -- End of Fix for WWBUG 1408379
308   --
309   hr_utility.set_location(' Leaving:'||l_proc, 10);
310 End post_insert;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< ins >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure ins
316   (p_rec            in out nocopy per_kad_shd.g_rec_type
317   ,p_validate       in     boolean default false
318   ,p_effective_date in     date
319   ) is
320 --
321   l_proc  varchar2(72) := g_package||'ins';
322 --
323 Begin
324   hr_utility.set_location('Entering:'||l_proc, 5);
325   --
326   -- Determine if the business process is to be validated.
327   --
328   If p_validate then
329     --
330     -- Issue the savepoint.
331     --
332     SAVEPOINT ins_per_add;
333   End If;
334   --
335   -- Call the supporting insert validate operations
336   --
337   per_kad_bus.insert_validate(p_rec
338                              ,p_effective_date
339                              );
340   --
341   -- Call the supporting pre-insert operation
342   --
343   pre_insert(p_rec);
344   --
345   -- Insert the row
346   --
347   insert_dml(p_rec);
348   --
349   -- Call the supporting post-insert operation
350   --
351   post_insert(p_rec,p_effective_date);
352   --
353   -- If we are validating then raise the Validate_Enabled exception
354   --
355   If p_validate then
356     Raise HR_Api.Validate_Enabled;
357   End If;
358   --
359   hr_utility.set_location(' Leaving:'||l_proc, 10);
360 Exception
361   When HR_Api.Validate_Enabled Then
362     --
363     -- As the Validate_Enabled exception has been raised
364     -- we must rollback to the savepoint
365     --
366     ROLLBACK TO ins_per_add;
367 end ins;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |---------------------------------< ins >----------------------------------|
371 -- ----------------------------------------------------------------------------
372 Procedure ins
373   (p_address_id                   out nocopy number
374   ,p_business_group_id            in number
375   ,p_person_id                    in number
376   ,p_date_from                    in date
377   ,p_primary_flag                 in varchar2
378   ,p_style                        in varchar2
379   ,p_address_line1                in varchar2         default null
380   ,p_address_line2                in varchar2         default null
381   ,p_address_line3                in varchar2         default null
382   ,p_address_type                 in varchar2         default null
383   ,p_comments                     in clob             default null
384   ,p_country                      in varchar2         default null
385   ,p_date_to                      in date             default null
386   ,p_postal_code                  in varchar2         default null
387   ,p_region_1                     in varchar2         default null
388   ,p_region_2                     in varchar2         default null
389   ,p_region_3                     in varchar2         default null
390   ,p_telephone_number_1           in varchar2         default null
391   ,p_telephone_number_2           in varchar2         default null
392   ,p_telephone_number_3           in varchar2         default null
393   ,p_town_or_city                 in varchar2         default null
394   ,p_request_id                   in number           default null
395   ,p_program_application_id       in number           default null
396   ,p_program_id                   in number           default null
397   ,p_program_update_date          in date             default null
398   ,p_addr_attribute_category      in varchar2         default null
399   ,p_addr_attribute1              in varchar2         default null
400   ,p_addr_attribute2              in varchar2         default null
401   ,p_addr_attribute3              in varchar2         default null
402   ,p_addr_attribute4              in varchar2         default null
403   ,p_addr_attribute5              in varchar2         default null
404   ,p_addr_attribute6              in varchar2         default null
405   ,p_addr_attribute7              in varchar2         default null
406   ,p_addr_attribute8              in varchar2         default null
407   ,p_addr_attribute9              in varchar2         default null
408   ,p_addr_attribute10             in varchar2         default null
409   ,p_addr_attribute11             in varchar2         default null
410   ,p_addr_attribute12             in varchar2         default null
411   ,p_addr_attribute13             in varchar2         default null
412   ,p_addr_attribute14             in varchar2         default null
413   ,p_addr_attribute15             in varchar2         default null
414   ,p_addr_attribute16             in varchar2         default null
415   ,p_addr_attribute17             in varchar2         default null
416   ,p_addr_attribute18             in varchar2         default null
417   ,p_addr_attribute19             in varchar2         default null
418   ,p_addr_attribute20             in varchar2         default null
419   ,p_object_version_number        out nocopy number
420   ,p_validate                     in boolean          default false
421   ,p_effective_date               in date
422   ) is
423 --
424   l_rec	  per_kad_shd.g_rec_type;
425   l_proc  varchar2(72) := g_package||'ins';
426 --
427 Begin
428   hr_utility.set_location('Entering:'||l_proc, 5);
429   --
430   -- Call conversion function to turn arguments into the
431   -- p_rec structure.
432   --
433   l_rec :=
434   per_kad_shd.convert_args
435   (
436   null,
437   p_business_group_id,
438   p_person_id,
439   p_date_from,
440   p_primary_flag,
441   p_style,
442   p_address_line1,
443   p_address_line2,
444   p_address_line3,
445   p_address_type,
446   p_comments,
447   p_country,
448   p_date_to,
449   p_postal_code,
450   p_region_1,
451   p_region_2,
452   p_region_3,
453   p_telephone_number_1,
454   p_telephone_number_2,
455   p_telephone_number_3,
456   p_town_or_city,
457   p_request_id,
458   p_program_application_id,
459   p_program_id,
460   p_program_update_date,
461   p_addr_attribute_category,
462   p_addr_attribute1,
463   p_addr_attribute2,
464   p_addr_attribute3,
465   p_addr_attribute4,
466   p_addr_attribute5,
467   p_addr_attribute6,
468   p_addr_attribute7,
469   p_addr_attribute8,
470   p_addr_attribute9,
471   p_addr_attribute10,
472   p_addr_attribute11,
473   p_addr_attribute12,
474   p_addr_attribute13,
475   p_addr_attribute14,
476   p_addr_attribute15,
477   p_addr_attribute16,
478   p_addr_attribute17,
479   p_addr_attribute18,
480   p_addr_attribute19,
481   p_addr_attribute20,
482   null
483   );
484   --
485   -- Having converted the arguments into the per_kad_rec
486   -- plsql record structure we call the corresponding record business process.
487   --
488   ins(l_rec
489      ,p_validate
490      ,p_effective_date
491      );
492   --
493   -- As the primary key argument(s)
494   -- are specified as an OUT's we must set these values.
495   --
496   p_address_id := l_rec.address_id;
497   p_object_version_number := l_rec.object_version_number;
498   --
499   hr_utility.set_location(' Leaving:'||l_proc, 10);
500 End ins;
501 --
502 end per_kad_ins;