DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_CTX_INS

Source


1 Package Body hr_ctx_ins as
2 /* $Header: hrctxrhi.pkb 120.0 2005/05/30 23:30 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_ctx_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_context_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_context_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   hr_ctx_ins.g_context_id_i := p_context_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy hr_ctx_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: hr_ki_contexts
88   --
89   insert into hr_ki_contexts
90       (context_id
91       ,view_name
92       ,param_1
93       ,param_2
94       ,param_3
95       ,param_4
96       ,param_5
97       ,param_6
98       ,param_7
99       ,param_8
100       ,param_9
101       ,param_10
102       ,param_11
103       ,param_12
104       ,param_13
105       ,param_14
106       ,param_15
107       ,param_16
108       ,param_17
109       ,param_18
110       ,param_19
111       ,param_20
112       ,param_21
113       ,param_22
114       ,param_23
115       ,param_24
116       ,param_25
117       ,param_26
118       ,param_27
119       ,param_28
120       ,param_29
121       ,param_30
122       ,object_version_number
123       )
124   Values
125     (p_rec.context_id
126     ,p_rec.view_name
127     ,p_rec.param_1
128     ,p_rec.param_2
129     ,p_rec.param_3
130     ,p_rec.param_4
131     ,p_rec.param_5
132     ,p_rec.param_6
133     ,p_rec.param_7
134     ,p_rec.param_8
135     ,p_rec.param_9
136     ,p_rec.param_10
137     ,p_rec.param_11
138     ,p_rec.param_12
139     ,p_rec.param_13
140     ,p_rec.param_14
141     ,p_rec.param_15
142     ,p_rec.param_16
143     ,p_rec.param_17
144     ,p_rec.param_18
145     ,p_rec.param_19
146     ,p_rec.param_20
147     ,p_rec.param_21
148     ,p_rec.param_22
149     ,p_rec.param_23
150     ,p_rec.param_24
151     ,p_rec.param_25
152     ,p_rec.param_26
153     ,p_rec.param_27
154     ,p_rec.param_28
155     ,p_rec.param_29
156     ,p_rec.param_30
157     ,p_rec.object_version_number
158     );
159   --
160   --
161   --
162   hr_utility.set_location(' Leaving:'||l_proc, 10);
163 Exception
164   When hr_api.check_integrity_violated Then
165     -- A check constraint has been violated
166     --
167     hr_ctx_shd.constraint_error
168       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
169   When hr_api.parent_integrity_violated Then
170     -- Parent integrity has been violated
171     --
172     hr_ctx_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     --
177     hr_ctx_shd.constraint_error
178       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
179   When Others Then
180     --
181     Raise;
182 End insert_dml;
183 --
184 -- ----------------------------------------------------------------------------
185 -- |------------------------------< pre_insert >------------------------------|
186 -- ----------------------------------------------------------------------------
187 -- {Start Of Comments}
188 --
189 -- Description:
190 --   This private procedure contains any processing which is required before
191 --   the insert dml. Presently, if the entity has a corresponding primary
192 --   key which is maintained by an associating sequence, the primary key for
193 --   the entity will be populated with the next sequence value in
194 --   preparation for the insert dml.
195 --
196 -- Prerequisites:
197 --   This is an internal procedure which is called from the ins procedure.
198 --
199 -- In Parameters:
200 --   A Pl/Sql record structure.
201 --
202 -- Post Success:
203 --   Processing continues.
204 --
205 -- Post Failure:
206 --   If an error has occurred, an error message and exception will be raised
207 --   but not handled.
208 --
209 -- Developer Implementation Notes:
210 --   Any pre-processing required before the insert dml is issued should be
211 --   coded within this procedure. As stated above, a good example is the
212 --   generation of a primary key number via a corresponding sequence.
213 --   It is important to note that any 3rd party maintenance should be reviewed
214 --   before placing in this procedure.
215 --
216 -- Access Status:
217 --   Internal Row Handler Use Only.
218 --
219 -- {End Of Comments}
220 -- ----------------------------------------------------------------------------
221 Procedure pre_insert
222   (p_rec  in out nocopy hr_ctx_shd.g_rec_type
223   ) is
224 --
225   Cursor C_Sel1 is select hr_ki_contexts_s.nextval from sys.dual;
226 --
227   Cursor C_Sel2 is
228     Select null
229       from hr_ki_contexts
230      where context_id =
231              hr_ctx_ins.g_context_id_i;
232 --
233   l_proc   varchar2(72) := g_package||'pre_insert';
234   l_exists varchar2(1);
235 --
236 Begin
237   hr_utility.set_location('Entering:'||l_proc, 5);
238   --
239   If (hr_ctx_ins.g_context_id_i is not null) Then
240     --
241     -- Verify registered primary key values not already in use
242     --
243     Open C_Sel2;
244     Fetch C_Sel2 into l_exists;
245     If C_Sel2%found Then
246        Close C_Sel2;
247        --
248        -- The primary key values are already in use.
249        --
250        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
251        fnd_message.set_token('TABLE_NAME','hr_ki_contexts');
252        fnd_message.raise_error;
253     End If;
254     Close C_Sel2;
255     --
256     -- Use registered key values and clear globals
257     --
258     p_rec.context_id :=
259       hr_ctx_ins.g_context_id_i;
260     hr_ctx_ins.g_context_id_i := null;
261   Else
262     --
263     -- No registerd key values, so select the next sequence number
264     --
265     --
266     -- Select the next sequence number
267     --
268     Open C_Sel1;
269     Fetch C_Sel1 Into p_rec.context_id;
270     Close C_Sel1;
271   End If;
272   --
273   hr_utility.set_location(' Leaving:'||l_proc, 10);
274 End pre_insert;
275 --
276 -- ----------------------------------------------------------------------------
277 -- |-----------------------------< post_insert >------------------------------|
278 -- ----------------------------------------------------------------------------
279 -- {Start Of Comments}
280 --
281 -- Description:
282 --   This private procedure contains any processing which is required after
283 --   the insert dml.
284 --
285 -- Prerequisites:
286 --   This is an internal procedure which is called from the ins procedure.
287 --
288 -- In Parameters:
289 --   A Pl/Sql record structre.
290 --
291 -- Post Success:
292 --   Processing continues.
293 --
294 -- Post Failure:
295 --   If an error has occurred, an error message and exception will be raised
296 --   but not handled.
297 --
298 -- Developer Implementation Notes:
299 --   Any post-processing required after the insert dml is issued should be
300 --   coded within this procedure. It is important to note that any 3rd party
301 --   maintenance should be reviewed before placing in this procedure.
302 --
303 -- Access Status:
304 --   Internal Row Handler Use Only.
305 --
306 -- {End Of Comments}
307 -- ----------------------------------------------------------------------------
308 Procedure post_insert
309   (p_rec                          in hr_ctx_shd.g_rec_type
310   ) is
311 --
312   l_proc  varchar2(72) := g_package||'post_insert';
313 --
314 Begin
315   hr_utility.set_location('Entering:'||l_proc, 5);
316   begin
317     --
318     hr_ctx_rki.after_insert
319       (p_context_id
320       => p_rec.context_id
321       ,p_view_name
322       => p_rec.view_name
323       ,p_param_1
324       => p_rec.param_1
325       ,p_param_2
326       => p_rec.param_2
327       ,p_param_3
328       => p_rec.param_3
329       ,p_param_4
330       => p_rec.param_4
331       ,p_param_5
332       => p_rec.param_5
333       ,p_param_6
334       => p_rec.param_6
335       ,p_param_7
336       => p_rec.param_7
337       ,p_param_8
338       => p_rec.param_8
339       ,p_param_9
340       => p_rec.param_9
341       ,p_param_10
342       => p_rec.param_10
343       ,p_param_11
344       => p_rec.param_11
345       ,p_param_12
346       => p_rec.param_12
347       ,p_param_13
348       => p_rec.param_13
349       ,p_param_14
350       => p_rec.param_14
351       ,p_param_15
352       => p_rec.param_15
353       ,p_param_16
354       => p_rec.param_16
355       ,p_param_17
356       => p_rec.param_17
357       ,p_param_18
358       => p_rec.param_18
359       ,p_param_19
360       => p_rec.param_19
361       ,p_param_20
362       => p_rec.param_20
363       ,p_param_21
364       => p_rec.param_21
365       ,p_param_22
366       => p_rec.param_22
367       ,p_param_23
368       => p_rec.param_23
369       ,p_param_24
370       => p_rec.param_24
371       ,p_param_25
372       => p_rec.param_25
373       ,p_param_26
374       => p_rec.param_26
375       ,p_param_27
376       => p_rec.param_27
377       ,p_param_28
378       => p_rec.param_28
379       ,p_param_29
380       => p_rec.param_29
381       ,p_param_30
382       => p_rec.param_30
383       ,p_object_version_number
384       => p_rec.object_version_number
385       );
386     --
387   exception
388     --
389     when hr_api.cannot_find_prog_unit then
390       --
391       hr_api.cannot_find_prog_unit_error
392         (p_module_name => 'HR_KI_CONTEXTS'
393         ,p_hook_type   => 'AI');
394       --
395   end;
396   --
397   hr_utility.set_location(' Leaving:'||l_proc, 10);
398 End post_insert;
399 --
400 -- ----------------------------------------------------------------------------
401 -- |---------------------------------< ins >----------------------------------|
402 -- ----------------------------------------------------------------------------
403 Procedure ins
404   (p_rec                          in out nocopy hr_ctx_shd.g_rec_type
405   ) is
406 --
407   l_proc  varchar2(72) := g_package||'ins';
408 --
409 Begin
410   hr_utility.set_location('Entering:'||l_proc, 5);
411   --
412   -- Call the supporting insert validate operations
413   --
414   hr_ctx_bus.insert_validate
415      (p_rec
416      );
417   --
418   -- Call to raise any errors on multi-message list
419   hr_multi_message.end_validation_set;
420   --
421   -- Call the supporting pre-insert operation
422   --
423   hr_ctx_ins.pre_insert(p_rec);
424   --
425   -- Insert the row
426   --
427   hr_ctx_ins.insert_dml(p_rec);
428   --
429   -- Call the supporting post-insert operation
430   --
431   hr_ctx_ins.post_insert
432      (p_rec
433      );
434   --
435   -- Call to raise any errors on multi-message list
436   hr_multi_message.end_validation_set;
437   --
438   hr_utility.set_location('Leaving:'||l_proc, 20);
439 end ins;
440 --
441 -- ----------------------------------------------------------------------------
442 -- |---------------------------------< ins >----------------------------------|
443 -- ----------------------------------------------------------------------------
444 Procedure ins
445   (p_view_name                      in     varchar2
446   ,p_param_1                        in     varchar2 default null
447   ,p_param_2                        in     varchar2 default null
448   ,p_param_3                        in     varchar2 default null
449   ,p_param_4                        in     varchar2 default null
450   ,p_param_5                        in     varchar2 default null
451   ,p_param_6                        in     varchar2 default null
452   ,p_param_7                        in     varchar2 default null
453   ,p_param_8                        in     varchar2 default null
454   ,p_param_9                        in     varchar2 default null
455   ,p_param_10                       in     varchar2 default null
456   ,p_param_11                       in     varchar2 default null
457   ,p_param_12                       in     varchar2 default null
458   ,p_param_13                       in     varchar2 default null
459   ,p_param_14                       in     varchar2 default null
460   ,p_param_15                       in     varchar2 default null
461   ,p_param_16                       in     varchar2 default null
462   ,p_param_17                       in     varchar2 default null
463   ,p_param_18                       in     varchar2 default null
464   ,p_param_19                       in     varchar2 default null
465   ,p_param_20                       in     varchar2 default null
466   ,p_param_21                       in     varchar2 default null
467   ,p_param_22                       in     varchar2 default null
468   ,p_param_23                       in     varchar2 default null
469   ,p_param_24                       in     varchar2 default null
470   ,p_param_25                       in     varchar2 default null
471   ,p_param_26                       in     varchar2 default null
472   ,p_param_27                       in     varchar2 default null
473   ,p_param_28                       in     varchar2 default null
474   ,p_param_29                       in     varchar2 default null
475   ,p_param_30                       in     varchar2 default null
476   ,p_context_id                        out nocopy number
477   ,p_object_version_number             out nocopy number
478   ) is
479 --
480   l_rec   hr_ctx_shd.g_rec_type;
481   l_proc  varchar2(72) := g_package||'ins';
482 --
483 Begin
484   hr_utility.set_location('Entering:'||l_proc, 5);
485   --
486   -- Call conversion function to turn arguments into the
487   -- p_rec structure.
488   --
489   l_rec :=
490   hr_ctx_shd.convert_args
491     (null
492     ,p_view_name
493     ,p_param_1
494     ,p_param_2
495     ,p_param_3
496     ,p_param_4
497     ,p_param_5
498     ,p_param_6
499     ,p_param_7
500     ,p_param_8
501     ,p_param_9
502     ,p_param_10
503     ,p_param_11
504     ,p_param_12
505     ,p_param_13
506     ,p_param_14
507     ,p_param_15
508     ,p_param_16
509     ,p_param_17
510     ,p_param_18
511     ,p_param_19
512     ,p_param_20
513     ,p_param_21
514     ,p_param_22
515     ,p_param_23
516     ,p_param_24
517     ,p_param_25
518     ,p_param_26
519     ,p_param_27
520     ,p_param_28
521     ,p_param_29
522     ,p_param_30
523     ,null
524     );
525   --
526   -- Having converted the arguments into the hr_ctx_rec
527   -- plsql record structure we call the corresponding record business process.
528   --
529   hr_ctx_ins.ins
530      (l_rec
531      );
532   --
533   -- As the primary key argument(s)
534   -- are specified as an OUT's we must set these values.
535   --
536   p_context_id := l_rec.context_id;
537   p_object_version_number := l_rec.object_version_number;
538   --
539   hr_utility.set_location(' Leaving:'||l_proc, 10);
540 End ins;
541 --
542 end hr_ctx_ins;