DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_POS_INS

Source


1 Package Body per_pos_ins as
2 /* $Header: peposrhi.pkb 120.0.12010000.1 2008/07/28 05:23:58 appldev ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_pos_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 --
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_pos_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_pos_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- PMFLETCH Using per_all_positions
64   --
65   -- Insert the row into: per_all_positions
66   --
67   insert into per_all_positions
68   (	position_id,
69 	business_group_id,
70 	job_id,
71 	organization_id,
72 	successor_position_id,
73 	relief_position_id,
74 	location_id,
75 	position_definition_id,
76 	date_effective,
77 	comments,
78 	date_end,
79 	frequency,
80 	name,
81 	probation_period,
82 	probation_period_units,
83 	replacement_required_flag,
84 	time_normal_finish,
85 	time_normal_start,
86         status,
87 	working_hours,
88 	request_id,
89 	program_application_id,
90 	program_id,
91 	program_update_date,
92 	attribute_category,
93 	attribute1,
94 	attribute2,
95 	attribute3,
96 	attribute4,
97 	attribute5,
98 	attribute6,
99 	attribute7,
100 	attribute8,
101 	attribute9,
102 	attribute10,
103 	attribute11,
104 	attribute12,
105 	attribute13,
106 	attribute14,
107 	attribute15,
108 	attribute16,
109 	attribute17,
110 	attribute18,
111 	attribute19,
112 	attribute20,
113 	object_version_number
114   )
115   Values
116   (	p_rec.position_id,
117 	p_rec.business_group_id,
118 	p_rec.job_id,
119 	p_rec.organization_id,
120 	p_rec.successor_position_id,
121 	p_rec.relief_position_id,
122 	p_rec.location_id,
123 	p_rec.position_definition_id,
124 	p_rec.date_effective,
125 	p_rec.comments,
126 	p_rec.date_end,
127 	p_rec.frequency,
128 	p_rec.name,
129 	p_rec.probation_period,
130 	p_rec.probation_period_units,
131 	p_rec.replacement_required_flag,
132 	p_rec.time_normal_finish,
133 	p_rec.time_normal_start,
134         p_rec.status,
135 	p_rec.working_hours,
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.attribute_category,
141 	p_rec.attribute1,
142 	p_rec.attribute2,
143 	p_rec.attribute3,
144 	p_rec.attribute4,
145 	p_rec.attribute5,
146 	p_rec.attribute6,
147 	p_rec.attribute7,
148 	p_rec.attribute8,
149 	p_rec.attribute9,
150 	p_rec.attribute10,
151 	p_rec.attribute11,
152 	p_rec.attribute12,
153 	p_rec.attribute13,
154 	p_rec.attribute14,
155 	p_rec.attribute15,
156 	p_rec.attribute16,
157 	p_rec.attribute17,
158 	p_rec.attribute18,
159 	p_rec.attribute19,
160 	p_rec.attribute20,
161 	p_rec.object_version_number
162   );
163   --
164   per_pos_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_pos_shd.g_api_dml := false;   -- Unset the api dml status
171     per_pos_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_pos_shd.g_api_dml := false;   -- Unset the api dml status
176     per_pos_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_pos_shd.g_api_dml := false;   -- Unset the api dml status
181     per_pos_shd.constraint_error
182       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
183   When Others Then
184     per_pos_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 --
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
216 --   generation of a primary key number via a corresponding sequence.
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_pos_shd.g_rec_type) is
226 --
227   l_proc  varchar2(72) := g_package||'pre_insert';
228 --
229   Cursor C_Sel1 is select hr_all_positions_f_s.nextval from sys.dual;
230 --
231 Begin
232   hr_utility.set_location('Entering:'||l_proc, 5);
233 -- if position_id is null the genrate sequence
234   --
235   --
236   -- Select the next sequence number
237   --
238   if p_rec.position_id is null then
239     Open C_Sel1;
240     Fetch C_Sel1 into p_rec.position_id;
241     Close C_Sel1;
242   end if;
243   --
244   --
245   hr_utility.set_location(' Leaving:'||l_proc, 10);
246 End pre_insert;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |-----------------------------< post_insert >------------------------------|
250 -- ----------------------------------------------------------------------------
251 -- {Start Of Comments}
252 --
253 -- Description:
254 --   This private procedure contains any processing which is required after the
255 --   insert dml.
256 --
257 -- Pre Conditions:
258 --   This is an internal procedure which is called from the ins procedure.
259 --
260 -- In Arguments:
261 --   A Pl/Sql record structre.
262 --
263 -- Post Success:
264 --   Processing continues.
265 --
266 -- Post Failure:
267 --   If an error has occurred, an error message and exception will be raised
268 --   but not handled.
269 --
270 -- Developer Implementation Notes:
271 --   Any post-processing required after the insert dml is issued should be
272 --   coded within this procedure. It is important to note that any 3rd party
273 --   maintenance should be reviewed before placing in this procedure.
274 --
275 -- Access Status:
276 --   Internal Table Handler Use Only.
277 --
278 -- {End Of Comments}
279 -- ----------------------------------------------------------------------------
280 Procedure post_insert(p_rec in per_pos_shd.g_rec_type) is
281 --
282   l_proc  varchar2(72) := g_package||'post_insert';
283 --
284 Begin
285   hr_utility.set_location('Entering:'||l_proc, 5);
286   --
287   -- Start of API User Hook for post_insert.
288   begin
289     per_pos_rki.after_insert
290       (p_position_id                  => p_rec.position_id
291       ,p_business_group_id            => p_rec.business_group_id
292       ,p_job_id                       => p_rec.job_id
293       ,p_organization_id              => p_rec.organization_id
294       ,p_successor_position_id        => p_rec.successor_position_id
295       ,p_relief_position_id           => p_rec.relief_position_id
296       ,p_location_id                  => p_rec.location_id
297       ,p_position_definition_id       => p_rec.position_definition_id
298       ,p_date_effective               => p_rec.date_effective
299       ,p_comments                     => p_rec.comments
300       ,p_date_end                     => p_rec.date_end
301       ,p_frequency                    => p_rec.frequency
302       ,p_name                         => p_rec.name
303       ,p_probation_period             => p_rec.probation_period
304       ,p_probation_period_units       => p_rec.probation_period_units
305       ,p_replacement_required_flag    => p_rec.replacement_required_flag
306       ,p_time_normal_finish           => p_rec.time_normal_finish
307       ,p_time_normal_start            => p_rec.time_normal_start
308       ,p_status                       => p_rec.status
309       ,p_working_hours                => p_rec.working_hours
310       ,p_request_id                   => p_rec.request_id
311       ,p_program_application_id       => p_rec.program_application_id
312       ,p_program_id                   => p_rec.program_id
313       ,p_program_update_date          => p_rec.program_update_date
314       ,p_attribute_category           => p_rec.attribute_category
315       ,p_attribute1                   => p_rec.attribute1
316       ,p_attribute2                   => p_rec.attribute2
317       ,p_attribute3                   => p_rec.attribute3
318       ,p_attribute4                   => p_rec.attribute4
319       ,p_attribute5                   => p_rec.attribute5
320       ,p_attribute6                   => p_rec.attribute6
321       ,p_attribute7                   => p_rec.attribute7
322       ,p_attribute8                   => p_rec.attribute8
323       ,p_attribute9                   => p_rec.attribute9
324       ,p_attribute10                  => p_rec.attribute10
325       ,p_attribute11                  => p_rec.attribute11
326       ,p_attribute12                  => p_rec.attribute12
327       ,p_attribute13                  => p_rec.attribute13
328       ,p_attribute14                  => p_rec.attribute14
329       ,p_attribute15                  => p_rec.attribute15
330       ,p_attribute16                  => p_rec.attribute16
331       ,p_attribute17                  => p_rec.attribute17
332       ,p_attribute18                  => p_rec.attribute18
333       ,p_attribute19                  => p_rec.attribute19
334       ,p_attribute20                  => p_rec.attribute20
335       ,p_object_version_number        => p_rec.object_version_number
336       );
337   exception
338     when hr_api.cannot_find_prog_unit then
339       hr_api.cannot_find_prog_unit_error
340         (p_module_name => 'PER_POSITIONS'
341         ,p_hook_type   => 'AI'
342         );
343   end;
344   -- End of API User Hook for post_insert.
345   --
346   hr_utility.set_location(' Leaving:'||l_proc, 10);
347 End post_insert;
348 --
349 -- ----------------------------------------------------------------------------
350 -- |---------------------------------< ins >----------------------------------|
351 -- ----------------------------------------------------------------------------
352 Procedure ins
353   (
354   p_rec        in out nocopy per_pos_shd.g_rec_type,
355   p_validate   in     boolean default false
356   ) is
357 --
358   l_proc  varchar2(72) := g_package||'ins';
359 --
360 Begin
361   hr_utility.set_location('Entering:'||l_proc, 5);
362   per_pos_shd.G_DT_INS:=TRUE;
363   --
364   -- Determine if the business process is to be validated.
365   --
366   If p_validate then
367     --
368     -- Issue the savepoint.
369     --
370     SAVEPOINT ins_per_pos;
371   End If;
372   --
373   -- Call the supporting insert validate operations
374   --
375   per_pos_bus.insert_validate(p_rec);
376   --
377   -- Call the supporting pre-insert operation
378   --
379   pre_insert(p_rec);
380   --
381   -- Insert the row
382   --
383   insert_dml(p_rec);
384   --
385   -- Call the supporting post-insert operation
386   --
387   post_insert(p_rec);
388   --
389   -- If we are validating then raise the Validate_Enabled exception
390   --
391   If p_validate then
392     Raise HR_Api.Validate_Enabled;
393   End If;
394   --
395   per_pos_shd.G_DT_INS:=FALSE;
396   --
397   hr_utility.set_location(' Leaving:'||l_proc, 10);
398 Exception
399   When HR_Api.Validate_Enabled Then
400     --
401     -- As the Validate_Enabled exception has been raised
402     -- we must rollback to the savepoint
403     --
404   per_pos_shd.G_DT_INS:=FALSE;
405   --
406     ROLLBACK TO ins_per_pos;
407 end ins;
408 --
409 -- ----------------------------------------------------------------------------
410 -- |---------------------------------< ins >----------------------------------|
411 -- ----------------------------------------------------------------------------
412 Procedure ins
413   (
414   p_position_id                  in out nocopy number,
415   p_business_group_id            in number,
416   p_job_id                       in number,
417   p_organization_id              in number,
418   p_successor_position_id        in number           default null,
419   p_relief_position_id           in number           default null,
420   p_location_id                  in number           default null,
421   p_position_definition_id       in number,
422   p_date_effective               in date,
423   p_comments                     in varchar2         default null,
424   p_date_end                     in date             default null,
425   p_frequency                    in varchar2         default null,
426   p_name                         in varchar2         default null,
427   p_probation_period             in number           default null,
428   p_probation_period_units       in varchar2         default null,
429   p_replacement_required_flag    in varchar2         default null,
430   p_time_normal_finish           in varchar2         default null,
431   p_time_normal_start            in varchar2         default null,
432   p_status                       in varchar2         default null,
433   p_working_hours                in number           default null,
434   p_request_id                   in number           default null,
435   p_program_application_id       in number           default null,
436   p_program_id                   in number           default null,
437   p_program_update_date          in date             default null,
438   p_attribute_category           in varchar2         default null,
439   p_attribute1                   in varchar2         default null,
440   p_attribute2                   in varchar2         default null,
441   p_attribute3                   in varchar2         default null,
442   p_attribute4                   in varchar2         default null,
443   p_attribute5                   in varchar2         default null,
444   p_attribute6                   in varchar2         default null,
445   p_attribute7                   in varchar2         default null,
446   p_attribute8                   in varchar2         default null,
447   p_attribute9                   in varchar2         default null,
448   p_attribute10                  in varchar2         default null,
449   p_attribute11                  in varchar2         default null,
450   p_attribute12                  in varchar2         default null,
451   p_attribute13                  in varchar2         default null,
452   p_attribute14                  in varchar2         default null,
453   p_attribute15                  in varchar2         default null,
454   p_attribute16                  in varchar2         default null,
455   p_attribute17                  in varchar2         default null,
456   p_attribute18                  in varchar2         default null,
457   p_attribute19                  in varchar2         default null,
458   p_attribute20                  in varchar2         default null,
459   p_object_version_number        out nocopy number,
460   p_validate                     in boolean          default false
461   ) is
462 --
463   l_rec	  per_pos_shd.g_rec_type;
464   l_proc  varchar2(72) := g_package||'ins';
465 --
466 Begin
467   hr_utility.set_location('Entering:'||l_proc, 5);
468   --
469   -- Call conversion function to turn arguments into the
470   -- p_rec structure.
471   --
472   l_rec :=
473   per_pos_shd.convert_args
474   (
475   p_position_id,
476   p_business_group_id,
477   p_job_id,
478   p_organization_id,
479   p_successor_position_id,
480   p_relief_position_id,
481   p_location_id,
482   p_position_definition_id,
483   p_date_effective,
484   p_comments,
485   p_date_end,
486   p_frequency,
487   p_name,
488   p_probation_period,
489   p_probation_period_units,
490   p_replacement_required_flag,
491   p_time_normal_finish,
492   p_time_normal_start,
493   p_status,
494   p_working_hours,
495   p_request_id,
496   p_program_application_id,
497   p_program_id,
498   p_program_update_date,
499   p_attribute_category,
500   p_attribute1,
501   p_attribute2,
502   p_attribute3,
503   p_attribute4,
504   p_attribute5,
505   p_attribute6,
506   p_attribute7,
507   p_attribute8,
508   p_attribute9,
509   p_attribute10,
510   p_attribute11,
511   p_attribute12,
512   p_attribute13,
513   p_attribute14,
514   p_attribute15,
515   p_attribute16,
516   p_attribute17,
517   p_attribute18,
518   p_attribute19,
519   p_attribute20,
520   null
521   );
522   --
523   -- Having converted the arguments into the per_pos_rec
524   -- plsql record structure we call the corresponding record business process.
525   --
526   ins(l_rec, p_validate);
527   --
528   -- As the primary key argument(s)
529   -- are specified as an OUT's we must set these values.
530   --
531   p_position_id := l_rec.position_id;
532   p_object_version_number := l_rec.object_version_number;
533   --
534   hr_utility.set_location(' Leaving:'||l_proc, 10);
535 End ins;
536 --
537 end per_pos_ins;