DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RMV_INS

Source


1 Package Body pqh_rmv_ins as
2 /* $Header: pqrmvrhi.pkb 120.2 2005/06/23 03:41 srenukun noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_rmv_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_node_value_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_node_value_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   pqh_rmv_ins.g_node_value_id_i := p_node_value_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |-----------------------< create_app_ownerships >--------------------------|
34 -- ----------------------------------------------------------------------------
35 --
36 -- Description:
37 --   This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
38 --   when the row handler is called in the appropriate mode.
39 --
40 -- ----------------------------------------------------------------------------
41 PROCEDURE create_app_ownerships(p_pk_column  IN varchar2
42                                ,p_pk_value   IN varchar2) IS
43 --
44 CURSOR csr_definition IS
45   SELECT product_short_name
46     FROM hr_owner_definitions
47    WHERE session_id = hr_startup_data_api_support.g_session_id;
48 --
49 BEGIN
50   --
51   IF (hr_startup_data_api_support.return_startup_mode IN
52                                ('STARTUP','GENERIC')) THEN
53      --
54      FOR c1 IN csr_definition LOOP
55        --
56        INSERT INTO hr_application_ownerships
57          (key_name
58          ,key_value
59          ,product_name
60          )
61        VALUES
62          (p_pk_column
63          ,fnd_number.number_to_canonical(p_pk_value)
64          ,c1.product_short_name
65          );
66      END LOOP;
67   END IF;
68 END create_app_ownerships;
69 --
70 -- ----------------------------------------------------------------------------
71 -- |-----------------------< create_app_ownerships >--------------------------|
72 -- ----------------------------------------------------------------------------
73 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
74                                ,p_pk_value  IN number) IS
75 --
76 BEGIN
77   create_app_ownerships(p_pk_column, to_char(p_pk_value));
78 END create_app_ownerships;
79 --
80 -- ----------------------------------------------------------------------------
81 -- |------------------------------< insert_dml >------------------------------|
82 -- ----------------------------------------------------------------------------
83 -- {Start Of Comments}
84 --
85 -- Description:
86 --   This procedure controls the actual dml insert logic. The processing of
87 --   this procedure are as follows:
88 --   1) Initialise the object_version_number to 1 if the object_version_number
89 --      is defined as an attribute for this entity.
90 --   2) To set and unset the g_api_dml status as required (as we are about to
91 --      perform dml).
92 --   3) To insert the row into the schema.
93 --   4) To trap any constraint violations that may have occurred.
94 --   5) To raise any other errors.
95 --
96 -- Prerequisites:
97 --   This is an internal private procedure which must be called from the ins
98 --   procedure and must have all mandatory attributes set (except the
99 --   object_version_number which is initialised within this procedure).
100 --
101 -- In Parameters:
102 --   A Pl/Sql record structre.
103 --
104 -- Post Success:
105 --   The specified row will be inserted into the schema.
106 --
107 -- Post Failure:
108 --   On the insert dml failure it is important to note that we always reset the
109 --   g_api_dml status to false.
110 --   If a check, unique or parent integrity constraint violation is raised the
111 --   constraint_error procedure will be called.
112 --   If any other error is reported, the error will be raised after the
113 --   g_api_dml status is reset.
114 --
115 -- Developer Implementation Notes:
116 --   None.
117 --
118 -- Access Status:
119 --   Internal Row Handler Use Only.
120 --
121 -- {End Of Comments}
122 -- ----------------------------------------------------------------------------
123 Procedure insert_dml
124   (p_rec in out nocopy pqh_rmv_shd.g_rec_type
125   ) is
126 --
127   l_proc  varchar2(72) := g_package||'insert_dml';
128 --
129 Begin
130   hr_utility.set_location('Entering:'||l_proc, 5);
131   p_rec.object_version_number := 1;  -- Initialise the object version
132   --
133   --
134   --
135   -- Insert the row into: pqh_rt_matrix_node_values
136   --
137   insert into pqh_rt_matrix_node_values
138       (node_value_id
139       ,rate_matrix_node_id
140       ,short_code
141       ,char_value1
142       ,char_value2
143       ,char_value3
144       ,char_value4
145       ,number_value1
146       ,number_value2
147       ,number_value3
148       ,number_value4
149       ,date_value1
150       ,date_value2
151       ,date_value3
152       ,date_value4
153       ,business_group_id
154       ,legislation_code
155       ,object_version_number
156       )
157   Values
158     (p_rec.node_value_id
159     ,p_rec.rate_matrix_node_id
160     ,p_rec.short_code
161     ,p_rec.char_value1
162     ,p_rec.char_value2
163     ,p_rec.char_value3
164     ,p_rec.char_value4
165     ,p_rec.number_value1
166     ,p_rec.number_value2
167     ,p_rec.number_value3
168     ,p_rec.number_value4
169     ,p_rec.date_value1
170     ,p_rec.date_value2
171     ,p_rec.date_value3
172     ,p_rec.date_value4
173     ,p_rec.business_group_id
174     ,p_rec.legislation_code
175     ,p_rec.object_version_number
176     );
177   --
178   --
179   --
180   hr_utility.set_location(' Leaving:'||l_proc, 10);
181 Exception
182   When hr_api.check_integrity_violated Then
183     -- A check constraint has been violated
184     --
185     pqh_rmv_shd.constraint_error
186       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
187   When hr_api.parent_integrity_violated Then
188     -- Parent integrity has been violated
189     --
190     pqh_rmv_shd.constraint_error
191       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
192   When hr_api.unique_integrity_violated Then
193     -- Unique integrity has been violated
194     --
195     pqh_rmv_shd.constraint_error
196       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
197   When Others Then
198     --
199     Raise;
200 End insert_dml;
201 --
202 -- ----------------------------------------------------------------------------
203 -- |------------------------------< pre_insert >------------------------------|
204 -- ----------------------------------------------------------------------------
205 -- {Start Of Comments}
206 --
207 -- Description:
208 --   This private procedure contains any processing which is required before
209 --   the insert dml. Presently, if the entity has a corresponding primary
210 --   key which is maintained by an associating sequence, the primary key for
211 --   the entity will be populated with the next sequence value in
212 --   preparation for the insert dml.
213 --
214 -- Prerequisites:
215 --   This is an internal procedure which is called from the ins procedure.
216 --
217 -- In Parameters:
218 --   A Pl/Sql record structure.
219 --
220 -- Post Success:
221 --   Processing continues.
222 --
223 -- Post Failure:
224 --   If an error has occurred, an error message and exception will be raised
225 --   but not handled.
226 --
227 -- Developer Implementation Notes:
228 --   Any pre-processing required before the insert dml is issued should be
229 --   coded within this procedure. As stated above, a good example is the
230 --   generation of a primary key number via a corresponding sequence.
231 --   It is important to note that any 3rd party maintenance should be reviewed
232 --   before placing in this procedure.
233 --
234 -- Access Status:
235 --   Internal Row Handler Use Only.
236 --
237 -- {End Of Comments}
238 -- ----------------------------------------------------------------------------
239 Procedure pre_insert
240   (p_rec  in out nocopy pqh_rmv_shd.g_rec_type
241   ) is
242 --
243   Cursor C_Sel1 is select pqh_rt_matrix_node_values_s.nextval from sys.dual;
244 --
245   Cursor C_Sel2 is
246     Select null
247       from pqh_rt_matrix_node_values
248      where node_value_id =
249              pqh_rmv_ins.g_node_value_id_i;
250 --
251   l_proc   varchar2(72) := g_package||'pre_insert';
252   l_exists varchar2(1);
253 --
254 Begin
255   hr_utility.set_location('Entering:'||l_proc, 5);
256   --
257   If (pqh_rmv_ins.g_node_value_id_i is not null) Then
258     --
259     -- Verify registered primary key values not already in use
260     --
261     Open C_Sel2;
262     Fetch C_Sel2 into l_exists;
263     If C_Sel2%found Then
264        Close C_Sel2;
265        --
266        -- The primary key values are already in use.
267        --
268        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
269        fnd_message.set_token('TABLE_NAME','pqh_rt_matrix_node_values');
270        fnd_message.raise_error;
271     End If;
272     Close C_Sel2;
273     --
274     -- Use registered key values and clear globals
275     --
276     p_rec.node_value_id :=
277       pqh_rmv_ins.g_node_value_id_i;
278     pqh_rmv_ins.g_node_value_id_i := null;
279   Else
280     --
281     -- No registerd key values, so select the next sequence number
282     --
283     --
284     -- Select the next sequence number
285     --
286     Open C_Sel1;
287     Fetch C_Sel1 Into p_rec.node_value_id;
288     Close C_Sel1;
289   End If;
290   --
291   hr_utility.set_location(' Leaving:'||l_proc, 10);
292 End pre_insert;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |-----------------------------< post_insert >------------------------------|
296 -- ----------------------------------------------------------------------------
297 -- {Start Of Comments}
298 --
299 -- Description:
300 --   This private procedure contains any processing which is required after
301 --   the insert dml.
302 --
303 -- Prerequisites:
304 --   This is an internal procedure which is called from the ins procedure.
305 --
306 -- In Parameters:
307 --   A Pl/Sql record structre.
308 --
309 -- Post Success:
310 --   Processing continues.
311 --
312 -- Post Failure:
313 --   If an error has occurred, an error message and exception will be raised
314 --   but not handled.
315 --
316 -- Developer Implementation Notes:
317 --   Any post-processing required after the insert dml is issued should be
318 --   coded within this procedure. It is important to note that any 3rd party
319 --   maintenance should be reviewed before placing in this procedure.
320 --
321 -- Access Status:
322 --   Internal Row Handler Use Only.
323 --
324 -- {End Of Comments}
325 -- ----------------------------------------------------------------------------
326 Procedure post_insert
327   (p_rec                          in pqh_rmv_shd.g_rec_type
328   ) is
329 --
330   l_proc  varchar2(72) := g_package||'post_insert';
331 --
332 Begin
333   hr_utility.set_location('Entering:'||l_proc, 5);
334   begin
335     --
336     -- insert ownerships if applicable
337     create_app_ownerships
338       ('NODE_VALUE_ID', p_rec.node_value_id
339       );
340     --
341     --
342     pqh_rmv_rki.after_insert
343       (p_node_value_id
344       => p_rec.node_value_id
345       ,p_rate_matrix_node_id
346       => p_rec.rate_matrix_node_id
347       ,p_short_code
348       => p_rec.short_code
349       ,p_char_value1
350       => p_rec.char_value1
351       ,p_char_value2
352       => p_rec.char_value2
353       ,p_char_value3
354       => p_rec.char_value3
355       ,p_char_value4
356       => p_rec.char_value4
357       ,p_number_value1
358       => p_rec.number_value1
359       ,p_number_value2
360       => p_rec.number_value2
361       ,p_number_value3
362       => p_rec.number_value3
363       ,p_number_value4
364       => p_rec.number_value4
365       ,p_date_value1
366       => p_rec.date_value1
367       ,p_date_value2
368       => p_rec.date_value2
369       ,p_date_value3
370       => p_rec.date_value3
371       ,p_date_value4
372       => p_rec.date_value4
373       ,p_business_group_id
374       => p_rec.business_group_id
375       ,p_legislation_code
376       => p_rec.legislation_code
377       ,p_object_version_number
378       => p_rec.object_version_number
379       );
380     --
381   exception
382     --
383     when hr_api.cannot_find_prog_unit then
384       --
385       hr_api.cannot_find_prog_unit_error
386         (p_module_name => 'PQH_RT_MATRIX_NODE_VALUES'
387         ,p_hook_type   => 'AI');
388       --
389   end;
390   --
391   hr_utility.set_location(' Leaving:'||l_proc, 10);
392 End post_insert;
393 --
394 -- ----------------------------------------------------------------------------
395 -- |---------------------------------< ins >----------------------------------|
396 -- ----------------------------------------------------------------------------
397 Procedure ins
398   (p_rec                          in out nocopy pqh_rmv_shd.g_rec_type
399   ) is
400 --
401   l_proc  varchar2(72) := g_package||'ins';
402 --
403 Begin
404   hr_utility.set_location('Entering:'||l_proc, 5);
405   --
406   -- Call the supporting insert validate operations
407   --
408   pqh_rmv_bus.insert_validate
409      (p_rec
410      );
411   --
412   -- Call to raise any errors on multi-message list
413   hr_multi_message.end_validation_set;
414   --
415   -- Call the supporting pre-insert operation
416   --
417   pqh_rmv_ins.pre_insert(p_rec);
418   --
419   -- Insert the row
420   --
421   pqh_rmv_ins.insert_dml(p_rec);
422   --
423   -- Call the supporting post-insert operation
424   --
425   pqh_rmv_ins.post_insert
426      (p_rec
427      );
428   --
429   -- Call to raise any errors on multi-message list
430   hr_multi_message.end_validation_set;
431   --
435 -- ----------------------------------------------------------------------------
432   hr_utility.set_location('Leaving:'||l_proc, 20);
433 end ins;
434 --
436 -- |---------------------------------< ins >----------------------------------|
437 -- ----------------------------------------------------------------------------
438 Procedure ins
439   (p_rate_matrix_node_id            in     number
440   ,p_short_code                     in     varchar2
441   ,p_char_value1                    in     varchar2 default null
442   ,p_char_value2                    in     varchar2 default null
443   ,p_char_value3                    in     varchar2 default null
444   ,p_char_value4                    in     varchar2 default null
445   ,p_number_value1                  in     number   default null
446   ,p_number_value2                  in     number   default null
447   ,p_number_value3                  in     number   default null
448   ,p_number_value4                  in     number   default null
449   ,p_date_value1                    in     date     default null
450   ,p_date_value2                    in     date     default null
451   ,p_date_value3                    in     date     default null
452   ,p_date_value4                    in     date     default null
453   ,p_business_group_id              in     number   default null
454   ,p_legislation_code               in     varchar2 default null
455   ,p_node_value_id                     out nocopy number
456   ,p_object_version_number             out nocopy number
457   ) is
458 --
459   l_rec   pqh_rmv_shd.g_rec_type;
460   l_proc  varchar2(72) := g_package||'ins';
461 --
462 Begin
463   hr_utility.set_location('Entering:'||l_proc, 5);
464   --
465   -- Call conversion function to turn arguments into the
466   -- p_rec structure.
467   --
468   l_rec :=
469   pqh_rmv_shd.convert_args
470     (null
471     ,p_rate_matrix_node_id
472     ,p_short_code
473     ,p_char_value1
474     ,p_char_value2
475     ,p_char_value3
476     ,p_char_value4
477     ,p_number_value1
478     ,p_number_value2
479     ,p_number_value3
480     ,p_number_value4
481     ,p_date_value1
482     ,p_date_value2
483     ,p_date_value3
484     ,p_date_value4
485     ,p_business_group_id
486     ,p_legislation_code
487     ,null
488     );
489   --
490   -- Having converted the arguments into the pqh_rmv_rec
491   -- plsql record structure we call the corresponding record business process.
492   --
493   pqh_rmv_ins.ins
494      (l_rec
495      );
496   --
497   -- As the primary key argument(s)
498   -- are specified as an OUT's we must set these values.
499   --
500   p_node_value_id := l_rec.node_value_id;
501   p_object_version_number := l_rec.object_version_number;
502   --
503   hr_utility.set_location(' Leaving:'||l_proc, 10);
504 End ins;
505 --
506 end pqh_rmv_ins;