DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_JBR_INS

Source


1 Package Body per_jbr_ins as
2 /* $Header: pejbrrhi.pkb 115.7 2002/12/06 10:18:00 pkakar ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_jbr_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_jbr_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_jbr_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: per_job_requirements
64   --
65   insert into per_job_requirements
66   (
67         job_requirement_id,
68         business_group_id,
69         analysis_criteria_id,
70         comments,
71         date_from,
72         date_to,
73         essential,
74         job_id,
75         position_id,
76         request_id,
77         program_application_id,
78         program_id,
79         program_update_date,
80         attribute_category,
81         attribute1,
82         attribute2,
83         attribute3,
84         attribute4,
85         attribute5,
86         attribute6,
87         attribute7,
88         attribute8,
89         attribute9,
90         attribute10,
91         attribute11,
92         attribute12,
93         attribute13,
94         attribute14,
95         attribute15,
96         attribute16,
97         attribute17,
98         attribute18,
99         attribute19,
100         attribute20,
101         object_version_number
102   )
103   Values
104   (
105         p_rec.job_requirement_id,
106         p_rec.business_group_id,
107         p_rec.analysis_criteria_id,
108         p_rec.comments,
109         p_rec.date_from,
110         p_rec.date_to,
111         p_rec.essential,
112         p_rec.job_id,
113         p_rec.position_id,
114         p_rec.request_id,
115         p_rec.program_application_id,
116         p_rec.program_id,
117         p_rec.program_update_date,
118         p_rec.attribute_category,
119         p_rec.attribute1,
120         p_rec.attribute2,
121         p_rec.attribute3,
122         p_rec.attribute4,
123         p_rec.attribute5,
124         p_rec.attribute6,
125         p_rec.attribute7,
126         p_rec.attribute8,
127         p_rec.attribute9,
128         p_rec.attribute10,
129         p_rec.attribute11,
130         p_rec.attribute12,
131         p_rec.attribute13,
132         p_rec.attribute14,
133         p_rec.attribute15,
134         p_rec.attribute16,
135         p_rec.attribute17,
136         p_rec.attribute18,
137         p_rec.attribute19,
138         p_rec.attribute20,
139         p_rec.object_version_number
140   );
141   --
142   per_jbr_shd.g_api_dml := false;   -- Unset the api dml status
143   --
144   hr_utility.set_location(' Leaving:'||l_proc, 10);
145 Exception
146   When hr_api.check_integrity_violated Then
147     -- A check constraint has been violated
148     per_jbr_shd.g_api_dml := false;   -- Unset the api dml status
149     per_jbr_shd.constraint_error
150       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
151   When hr_api.parent_integrity_violated Then
152     -- Parent integrity has been violated
153     per_jbr_shd.g_api_dml := false;   -- Unset the api dml status
154     per_jbr_shd.constraint_error
155       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
156   When hr_api.unique_integrity_violated Then
157     -- Unique integrity has been violated
158     per_jbr_shd.g_api_dml := false;   -- Unset the api dml status
159     per_jbr_shd.constraint_error
160       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
161   When Others Then
162     per_jbr_shd.g_api_dml := false;   -- Unset the api dml status
163     Raise;
164 End insert_dml;
165 --
166 -- ----------------------------------------------------------------------------
167 -- |------------------------------< pre_insert >------------------------------|
168 -- ----------------------------------------------------------------------------
169 -- {Start Of Comments}
170 --
171 -- Description:
172 --   This private procedure contains any processing which is required before
173 --   the insert dml. Presently, if the entity has a corresponding primary
174 --   key which is maintained by an associating sequence, the primary key for
175 --   the entity will be populated with the next sequence value in
176 --   preparation for the insert dml.
177 --
178 -- Pre Conditions:
179 --   This is an internal procedure which is called from the ins procedure.
180 --
181 -- In Arguments:
182 --   A Pl/Sql record structre.
183 --
184 -- Post Success:
185 --   Processing continues.
186 --
187 -- Post Failure:
188 --   If an error has occurred, an error message and exception will be raised
189 --   but not handled.
190 --
191 -- Developer Implementation Notes:
192 --   Any pre-processing required before the insert dml is issued should be
193 --   coded within this procedure. As stated above, a good example is the
194 --   generation of a primary key number via a corresponding sequence.
195 --   It is important to note that any 3rd party maintenance should be reviewed
196 --   before placing in this procedure.
197 --
198 -- Access Status:
199 --   Internal Table Handler Use Only.
200 --
201 -- {End Of Comments}
202 -- ----------------------------------------------------------------------------
203 Procedure pre_insert(p_rec  in out nocopy per_jbr_shd.g_rec_type) is
204 --
205   l_proc  varchar2(72) := g_package||'pre_insert';
206 --
207   Cursor C_Sel1 is select per_job_requirements_s.nextval from sys.dual;
208 --
209 Begin
210   hr_utility.set_location('Entering:'||l_proc, 5);
211   --
212   --
213   -- Select the next sequence number
214   --
215   Open C_Sel1;
216   Fetch C_Sel1 Into p_rec.job_requirement_id;
217   Close C_Sel1;
218   --
219   hr_utility.set_location(' Leaving:'||l_proc, 10);
220 End pre_insert;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |-----------------------------< post_insert >------------------------------|
224 -- ----------------------------------------------------------------------------
225 -- {Start Of Comments}
226 --
227 -- Description:
228 --   This private procedure contains any processing which is required after the
229 --   insert dml.
230 --
231 -- Pre Conditions:
232 --   This is an internal procedure which is called from the ins procedure.
233 --
234 -- In Arguments:
235 --   A Pl/Sql record structre.
236 --
237 -- Post Success:
238 --   Processing continues.
239 --
240 -- Post Failure:
241 --   If an error has occurred, an error message and exception will be raised
242 --   but not handled.
243 --
244 -- Developer Implementation Notes:
245 --   Any post-processing required after the insert dml is issued should be
246 --   coded within this procedure. It is important to note that any 3rd party
247 --   maintenance should be reviewed before placing in this procedure.
248 --
249 -- Access Status:
250 --   Internal Table Handler Use Only.
251 --
252 -- {End Of Comments}
253 -- ----------------------------------------------------------------------------
254 Procedure post_insert(p_rec in per_jbr_shd.g_rec_type) is
255 --
256   l_proc  varchar2(72) := g_package||'post_insert';
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   -- Start of API User Hook for post_insert.
262   --
263   begin
264     per_jbr_rki.after_insert
265       (
266        p_job_requirement_id            => p_rec.job_requirement_id,
267        p_business_group_id             => p_rec.business_group_id,
268        p_analysis_criteria_id          => p_rec.analysis_criteria_id,
269        p_comments                      => p_rec.comments,
270        p_date_from                     => p_rec.date_from,
271        p_date_to                       => p_rec.date_to,
272        p_essential                     => p_rec.essential,
273        p_job_id                        => p_rec.job_id,
274        p_position_id                   => p_rec.position_id,
275        p_request_id                    => p_rec.request_id,
276        p_program_application_id        => p_rec.program_application_id,
277        p_program_id                    => p_rec.program_id,
278        p_program_update_date           => p_rec.program_update_date,
279        p_attribute_category            => p_rec.attribute_category,
280        p_attribute1                    => p_rec.attribute1,
281        p_attribute2                    => p_rec.attribute2,
282        p_attribute3                    => p_rec.attribute3,
283        p_attribute4                    => p_rec.attribute4,
284        p_attribute5                    => p_rec.attribute5,
285        p_attribute6                    => p_rec.attribute6,
286        p_attribute7                    => p_rec.attribute7,
287        p_attribute8                    => p_rec.attribute8,
288        p_attribute9                    => p_rec.attribute9,
289        p_attribute10                   => p_rec.attribute10,
290        p_attribute11                   => p_rec.attribute11,
291        p_attribute12                   => p_rec.attribute12,
292        p_attribute13                   => p_rec.attribute13,
293        p_attribute14                   => p_rec.attribute14,
294        p_attribute15                   => p_rec.attribute15,
295        p_attribute16                   => p_rec.attribute16,
296        p_attribute17                   => p_rec.attribute17,
297        p_attribute18                   => p_rec.attribute18,
298        p_attribute19                   => p_rec.attribute19,
299        p_attribute20                   => p_rec.attribute20,
300        p_object_version_number         => p_rec.object_version_number
301       );
302   exception
303     when hr_api.cannot_find_prog_unit then
304       hr_api.cannot_find_prog_unit_error
305         (p_module_name => 'PER_JOB_REQUIREMENTS'
306         ,p_hook_type   => 'AI'
307         );
308   end;
309   -- End of API User Hook for post_insert.
310   --
311   hr_utility.set_location(' Leaving:'||l_proc, 10);
312 End post_insert;
313 --
314 -- ----------------------------------------------------------------------------
315 -- |---------------------------------< ins >----------------------------------|
316 -- ----------------------------------------------------------------------------
317 Procedure ins
318   (
319    p_rec        in out nocopy per_jbr_shd.g_rec_type,
320    p_validate   in     boolean default false
321   ) is
322 --
323   l_proc  varchar2(72) := g_package||'ins';
324 --
325 Begin
326   hr_utility.set_location('Entering:'||l_proc, 5);
327   --
328   -- Determine if the business process is to be validated.
329   --
330   If p_validate then
331     --
332     -- Issue the savepoint.
333     --
334     SAVEPOINT ins_per_jbr;
335   End If;
336   --
337   -- Call the supporting insert validate operations
338   --
339   per_jbr_bus.insert_validate(p_rec);
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);
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_jbr;
367 end ins;
368 --
369 -- ----------------------------------------------------------------------------
370 -- |---------------------------------< ins >----------------------------------|
371 -- ----------------------------------------------------------------------------
372 Procedure ins
373   (
374    p_job_requirement_id           out nocopy number,
375    p_business_group_id            in number,
376    p_analysis_criteria_id         in number,
377    p_comments                     in varchar2         default null,
378    p_date_from                    in date             default null,
379    p_date_to                      in date             default null,
380    p_essential                    in varchar2         default 'N',
381    p_job_id                       in number           default null,
382    p_position_id                  in number           default null,
383    p_request_id                   in number           default null,
384    p_program_application_id       in number           default null,
385    p_program_id                   in number           default null,
386    p_program_update_date          in date             default null,
387    p_attribute_category           in varchar2         default null,
388    p_attribute1                   in varchar2         default null,
389    p_attribute2                   in varchar2         default null,
390    p_attribute3                   in varchar2         default null,
391    p_attribute4                   in varchar2         default null,
392    p_attribute5                   in varchar2         default null,
393    p_attribute6                   in varchar2         default null,
394    p_attribute7                   in varchar2         default null,
395    p_attribute8                   in varchar2         default null,
396    p_attribute9                   in varchar2         default null,
397    p_attribute10                  in varchar2         default null,
398    p_attribute11                  in varchar2         default null,
399    p_attribute12                  in varchar2         default null,
400    p_attribute13                  in varchar2         default null,
401    p_attribute14                  in varchar2         default null,
402    p_attribute15                  in varchar2         default null,
403    p_attribute16                  in varchar2         default null,
404    p_attribute17                  in varchar2         default null,
405    p_attribute18                  in varchar2         default null,
406    p_attribute19                  in varchar2         default null,
407    p_attribute20                  in varchar2         default null,
408    p_object_version_number        out nocopy number,
409    p_validate                     in boolean   default false
410   ) is
411 --
412   l_rec	  per_jbr_shd.g_rec_type;
413   l_proc  varchar2(72) := g_package||'ins';
414 --
415 Begin
416   hr_utility.set_location('Entering:'||l_proc, 5);
417   --
418   -- Call conversion function to turn arguments into the
419   -- p_rec structure.
420   --
421   l_rec :=
422   per_jbr_shd.convert_args
423   (
424   null,
425   p_business_group_id,
426   p_analysis_criteria_id,
427   p_comments,
428   p_date_from,
429   p_date_to,
430   p_essential,
431   p_job_id,
432   p_position_id,
433   p_request_id,
434   p_program_application_id,
435   p_program_id,
436   p_program_update_date,
437   p_attribute_category,
438   p_attribute1,
439   p_attribute2,
440   p_attribute3,
441   p_attribute4,
442   p_attribute5,
443   p_attribute6,
444   p_attribute7,
445   p_attribute8,
446   p_attribute9,
447   p_attribute10,
448   p_attribute11,
449   p_attribute12,
450   p_attribute13,
451   p_attribute14,
452   p_attribute15,
453   p_attribute16,
454   p_attribute17,
455   p_attribute18,
456   p_attribute19,
457   p_attribute20,
458   null
459   );
460   --
461   -- Having converted the arguments into the per_jbr_rec
462   -- plsql record structure we call the corresponding record business process.
463   --
464   ins(l_rec, p_validate);
465   --
466   -- As the primary key argument(s)
467   -- are specified as an OUT's we must set these values.
468   --
469   p_job_requirement_id := l_rec.job_requirement_id;
470   p_object_version_number := l_rec.object_version_number;
471   --
472   hr_utility.set_location(' Leaving:'||l_proc, 10);
473 End ins;
474 --
475 end per_jbr_ins;