DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_TIS_INS

Source


1 Package Body hr_tis_ins as
2 /* $Header: hrtisrhi.pkb 120.3 2008/02/25 13:24:06 avarri ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  hr_tis_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_topic_integrations_id_i  number   default null;
14 --
18 procedure set_base_key_value
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
19   (p_topic_integrations_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_tis_ins.g_topic_integrations_id_i := p_topic_integrations_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_tis_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_topic_integrations
88   --
89   insert into hr_ki_topic_integrations
90       (topic_integrations_id
91       ,topic_id
92       ,integration_id
93       ,param_name1
94       ,param_value1
95       ,param_name2
96       ,param_value2
97       ,param_name3
98       ,param_value3
99       ,param_name4
100       ,param_value4
101       ,param_name5
102       ,param_value5
103       ,param_name6
104       ,param_value6
105       ,param_name7
106       ,param_value7
107       ,param_name8
108       ,param_value8
109       ,param_name9
110       ,param_value9
111       ,param_name10
112       ,param_value10
113       ,object_version_number
114       )
115   Values
116     (p_rec.topic_integrations_id
117     ,p_rec.topic_id
118     ,p_rec.integration_id
119     ,p_rec.param_name1
120     ,p_rec.param_value1
121     ,p_rec.param_name2
122     ,p_rec.param_value2
123     ,p_rec.param_name3
124     ,p_rec.param_value3
125     ,p_rec.param_name4
126     ,p_rec.param_value4
127     ,p_rec.param_name5
128     ,p_rec.param_value5
129     ,p_rec.param_name6
130     ,p_rec.param_value6
131     ,p_rec.param_name7
132     ,p_rec.param_value7
133     ,p_rec.param_name8
134     ,p_rec.param_value8
135     ,p_rec.param_name9
136     ,p_rec.param_value9
137     ,p_rec.param_name10
138     ,p_rec.param_value10
139     ,p_rec.object_version_number
140     );
141   --
142   --
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     --
149     hr_tis_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     --
154     hr_tis_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     --
159     hr_tis_shd.constraint_error
160       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
161   When Others Then
162     --
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
176 --   preparation for the insert dml.
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
177 --
178 -- Prerequisites:
179 --   This is an internal procedure which is called from the ins procedure.
180 --
181 -- In Parameters:
182 --   A Pl/Sql record structure.
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 Row Handler Use Only.
200 --
201 -- {End Of Comments}
202 -- ----------------------------------------------------------------------------
203 Procedure pre_insert
204   (p_rec  in out nocopy hr_tis_shd.g_rec_type
205   ) is
206 --
207   Cursor C_Sel1 is select hr_ki_topic_integrations_s.nextval from sys.dual;
208 --
209   Cursor C_Sel2 is
210     Select null
211       from hr_ki_topic_integrations
212      where topic_integrations_id =
213              hr_tis_ins.g_topic_integrations_id_i;
214 --
215   l_proc   varchar2(72) := g_package||'pre_insert';
216   l_exists varchar2(1);
217 --
218 Begin
219   hr_utility.set_location('Entering:'||l_proc, 5);
220   --
221   If (hr_tis_ins.g_topic_integrations_id_i is not null) Then
222     --
223     -- Verify registered primary key values not already in use
224     --
225     Open C_Sel2;
226     Fetch C_Sel2 into l_exists;
227     If C_Sel2%found Then
228        Close C_Sel2;
229        --
230        -- The primary key values are already in use.
231        --
232        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
233        fnd_message.set_token('TABLE_NAME','hr_ki_topic_integrations');
234        fnd_message.raise_error;
235     End If;
236     Close C_Sel2;
237     --
238     -- Use registered key values and clear globals
239     --
240     p_rec.topic_integrations_id :=
241       hr_tis_ins.g_topic_integrations_id_i;
242     hr_tis_ins.g_topic_integrations_id_i := null;
243   Else
244     --
245     -- No registerd key values, so select the next sequence number
246     --
247     --
248     -- Select the next sequence number
249     --
250     Open C_Sel1;
251     Fetch C_Sel1 Into p_rec.topic_integrations_id;
252     Close C_Sel1;
253   End If;
254   --
255   hr_utility.set_location(' Leaving:'||l_proc, 10);
256 End pre_insert;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |-----------------------------< post_insert >------------------------------|
260 -- ----------------------------------------------------------------------------
261 -- {Start Of Comments}
262 --
263 -- Description:
264 --   This private procedure contains any processing which is required after
265 --   the insert dml.
266 --
267 -- Prerequisites:
268 --   This is an internal procedure which is called from the ins procedure.
269 --
270 -- In Parameters:
271 --   A Pl/Sql record structre.
272 --
273 -- Post Success:
274 --   Processing continues.
275 --
276 -- Post Failure:
277 --   If an error has occurred, an error message and exception will be raised
278 --   but not handled.
279 --
280 -- Developer Implementation Notes:
281 --   Any post-processing required after the insert dml is issued should be
282 --   coded within this procedure. It is important to note that any 3rd party
283 --   maintenance should be reviewed before placing in this procedure.
284 --
285 -- Access Status:
286 --   Internal Row Handler Use Only.
287 --
288 -- {End Of Comments}
289 -- ----------------------------------------------------------------------------
290 Procedure post_insert
291   (p_rec                          in hr_tis_shd.g_rec_type
292   ) is
293 --
294   l_proc  varchar2(72) := g_package||'post_insert';
295 --
296 Begin
297   hr_utility.set_location('Entering:'||l_proc, 5);
298   begin
299     --
300     hr_tis_rki.after_insert
301       (p_topic_integrations_id  => p_rec.topic_integrations_id
302       ,p_topic_id               => p_rec.topic_id
303       ,p_integration_id         => p_rec.integration_id
304       ,p_param_name1            => p_rec.param_name1
305       ,p_param_value1           => p_rec.param_value1
306       ,p_param_name2            => p_rec.param_name2
307       ,p_param_value2           => p_rec.param_value2
308       ,p_param_name3            => p_rec.param_name3
309       ,p_param_value3           => p_rec.param_value3
310       ,p_param_name4            => p_rec.param_name4
311       ,p_param_value4           => p_rec.param_value4
312       ,p_param_name5            => p_rec.param_name5
313       ,p_param_value5           => p_rec.param_value5
314       ,p_param_name6            => p_rec.param_name6
315       ,p_param_value6           => p_rec.param_value6
316       ,p_param_name7            => p_rec.param_name7
317       ,p_param_value7           => p_rec.param_value7
318       ,p_param_name8            => p_rec.param_name8
319       ,p_param_value8           => p_rec.param_value8
320       ,p_param_name9            => p_rec.param_name9
321       ,p_param_value9           => p_rec.param_value9
322       ,p_param_name10           => p_rec.param_name10
323       ,p_param_value10          => p_rec.param_value10
324       ,p_object_version_number  => p_rec.object_version_number
325       );
326     --
327   exception
328     --
329     when hr_api.cannot_find_prog_unit then
330       --
331       hr_api.cannot_find_prog_unit_error
332         (p_module_name => 'HR_KI_TOPIC_INTEGRATIONS'
333         ,p_hook_type   => 'AI');
334       --
335   end;
336   --
337   hr_utility.set_location(' Leaving:'||l_proc, 10);
338 End post_insert;
339 --
340 -- ----------------------------------------------------------------------------
341 -- |---------------------------------< ins >----------------------------------|
342 -- ----------------------------------------------------------------------------
343 Procedure ins
344   (p_rec                          in out nocopy hr_tis_shd.g_rec_type
345   ) is
346 --
347   l_proc  varchar2(72) := g_package||'ins';
348 --
349 Begin
350   hr_utility.set_location('Entering:'||l_proc, 5);
351   --
352   -- Call the supporting insert validate operations
353   --
354   hr_tis_bus.insert_validate
355      (p_rec
356      );
357   --
358   -- Call to raise any errors on multi-message list
359   hr_multi_message.end_validation_set;
360   --
361   -- Call the supporting pre-insert operation
362   --
363   hr_tis_ins.pre_insert(p_rec);
364   --
365   -- Insert the row
366   --
367   hr_tis_ins.insert_dml(p_rec);
368   --
369   -- Call the supporting post-insert operation
370   --
371   hr_tis_ins.post_insert
372      (p_rec
373      );
374   --
375   -- Call to raise any errors on multi-message list
376   hr_multi_message.end_validation_set;
377   --
378   hr_utility.set_location('Leaving:'||l_proc, 20);
379 end ins;
380 --
381 -- ----------------------------------------------------------------------------
382 -- |---------------------------------< ins >----------------------------------|
383 -- ----------------------------------------------------------------------------
384 Procedure ins
385   (p_topic_id                      in     number
386   ,p_integration_id                in     number
387   ,p_param_name1                   in     varchar2 default null
388   ,p_param_value1                  in     varchar2 default null
389   ,p_param_name2                   in     varchar2 default null
390   ,p_param_value2                  in     varchar2 default null
391   ,p_param_name3                   in     varchar2 default null
392   ,p_param_value3                  in     varchar2 default null
393   ,p_param_name4                   in     varchar2 default null
394   ,p_param_value4                  in     varchar2 default null
395   ,p_param_name5                   in     varchar2 default null
396   ,p_param_value5                  in     varchar2 default null
397   ,p_param_name6                   in     varchar2 default null
398   ,p_param_value6                  in     varchar2 default null
399   ,p_param_name7                   in     varchar2 default null
400   ,p_param_value7                  in     varchar2 default null
401   ,p_param_name8                   in     varchar2 default null
402   ,p_param_value8                  in     varchar2 default null
403   ,p_param_name9                   in     varchar2 default null
404   ,p_param_value9                  in     varchar2 default null
405   ,p_param_name10                  in     varchar2 default null
406   ,p_param_value10                 in     varchar2 default null
407   ,p_topic_integrations_id         out nocopy number
408   ,p_object_version_number         out nocopy number
409   ) is
410 --
411   l_rec   hr_tis_shd.g_rec_type;
412   l_proc  varchar2(72) := g_package||'ins';
413 --
414 Begin
415   hr_utility.set_location('Entering:'||l_proc, 5);
416   --
417   -- Call conversion function to turn arguments into the
418   -- p_rec structure.
419   --
420   l_rec :=
421   hr_tis_shd.convert_args
422     (null
423     ,p_topic_id
424     ,p_integration_id
425     ,p_param_name1
426     ,p_param_value1
427     ,p_param_name2
428     ,p_param_value2
429     ,p_param_name3
430     ,p_param_value3
431     ,p_param_name4
432     ,p_param_value4
433     ,p_param_name5
434     ,p_param_value5
435     ,p_param_name6
436     ,p_param_value6
437     ,p_param_name7
438     ,p_param_value7
439     ,p_param_name8
440     ,p_param_value8
441     ,p_param_name9
442     ,p_param_value9
443     ,p_param_name10
444     ,p_param_value10
445     ,null
446     );
447   --
448   -- Having converted the arguments into the hr_tis_rec
449   -- plsql record structure we call the corresponding record business process.
450   --
451   hr_tis_ins.ins
452      (l_rec
453      );
454   --
455   -- As the primary key argument(s)
456   -- are specified as an OUT's we must set these values.
457   --
458   p_topic_integrations_id := l_rec.topic_integrations_id;
459   p_object_version_number := l_rec.object_version_number;
460   --
461   hr_utility.set_location(' Leaving:'||l_proc, 10);
462 End ins;
463 --
464 end hr_tis_ins;