DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CGN_INS

Source


1 Package Body pqh_cgn_ins as
2 /* $Header: pqcgnrhi.pkb 115.7 2002/11/27 04:43:27 rpasapul noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  pqh_cgn_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_case_group_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_case_group_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_cgn_ins.g_case_group_id_i := p_case_group_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 pqh_cgn_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: pqh_de_case_groups
88   --
89   insert into pqh_de_case_groups
90       (case_group_id
91       ,case_group_number
92       ,description
93       ,advanced_pay_grade
94       ,entries_in_minute
95       ,period_of_prob_advmnt
96       ,period_of_time_advmnt
97       ,advancement_to
98       ,object_version_number
99       ,advancement_additional_pyt
100       ,time_advanced_pay_grade
101       ,time_advancement_to
102       ,business_group_id
103       ,time_advn_units
104       ,prob_advn_units
105       ,sub_csgrp_description
106       )
107   Values
108     (p_rec.case_group_id
109     ,p_rec.case_group_number
110     ,p_rec.description
111     ,p_rec.advanced_pay_grade
112     ,p_rec.entries_in_minute
113     ,p_rec.period_of_prob_advmnt
114     ,p_rec.period_of_time_advmnt
115     ,p_rec.advancement_to
116     ,p_rec.object_version_number
117     ,p_rec.advancement_additional_pyt
118     ,p_rec.time_advanced_pay_grade
119     ,p_rec.time_advancement_to
120     ,p_rec.business_group_id
121     ,p_rec.time_advn_units
122     ,p_rec.prob_advn_units
123     ,p_rec.sub_csgrp_description
124     );
125   --
126   --
127   --
128   hr_utility.set_location(' Leaving:'||l_proc, 10);
129 Exception
130   When hr_api.check_integrity_violated Then
131     -- A check constraint has been violated
132     --
133     pqh_cgn_shd.constraint_error
134       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
135   When hr_api.parent_integrity_violated Then
136     -- Parent integrity has been violated
137     --
138     pqh_cgn_shd.constraint_error
139       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
140   When hr_api.unique_integrity_violated Then
141     -- Unique integrity has been violated
142     --
143     pqh_cgn_shd.constraint_error
144       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
145   When Others Then
146     --
147     Raise;
148 End insert_dml;
149 --
150 -- ----------------------------------------------------------------------------
151 -- |------------------------------< pre_insert >------------------------------|
152 -- ----------------------------------------------------------------------------
153 -- {Start Of Comments}
154 --
155 -- Description:
156 --   This private procedure contains any processing which is required before
157 --   the insert dml. Presently, if the entity has a corresponding primary
158 --   key which is maintained by an associating sequence, the primary key for
159 --   the entity will be populated with the next sequence value in
160 --   preparation for the insert dml.
161 --
162 -- Prerequisites:
163 --   This is an internal procedure which is called from the ins procedure.
164 --
165 -- In Parameters:
166 --   A Pl/Sql record structure.
167 --
168 -- Post Success:
169 --   Processing continues.
170 --
171 -- Post Failure:
172 --   If an error has occurred, an error message and exception will be raised
173 --   but not handled.
174 --
175 -- Developer Implementation Notes:
176 --   Any pre-processing required before the insert dml is issued should be
177 --   coded within this procedure. As stated above, a good example is the
178 --   generation of a primary key number via a corresponding sequence.
179 --   It is important to note that any 3rd party maintenance should be reviewed
180 --   before placing in this procedure.
181 --
182 -- Access Status:
183 --   Internal Row Handler Use Only.
184 --
185 -- {End Of Comments}
186 -- ----------------------------------------------------------------------------
187 Procedure pre_insert
188   (p_rec  in out nocopy pqh_cgn_shd.g_rec_type
189   ) is
190 --
191   Cursor C_Sel1 is select pqh_de_case_groups_s.nextval from sys.dual;
192 --
193   Cursor C_Sel2 is
194     Select null
195       from pqh_de_case_groups
196      where case_group_id =
197              pqh_cgn_ins.g_case_group_id_i;
198 --
199   l_proc   varchar2(72) := g_package||'pre_insert';
200   l_exists varchar2(1);
201 --
202 Begin
203   hr_utility.set_location('Entering:'||l_proc, 5);
204   --
205   If (pqh_cgn_ins.g_case_group_id_i is not null) Then
206     --
207     -- Verify registered primary key values not already in use
208     --
209     Open C_Sel2;
210     Fetch C_Sel2 into l_exists;
211     If C_Sel2%found Then
212        Close C_Sel2;
213        --
214        -- The primary key values are already in use.
215        --
216        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
217        fnd_message.set_token('TABLE_NAME','pqh_de_case_groups');
218        fnd_message.raise_error;
219     End If;
220     Close C_Sel2;
221     --
222     -- Use registered key values and clear globals
223     --
224     p_rec.case_group_id :=
225       pqh_cgn_ins.g_case_group_id_i;
226     pqh_cgn_ins.g_case_group_id_i := null;
227   Else
228     --
229     -- No registerd key values, so select the next sequence number
230     --
231     --
232     -- Select the next sequence number
233     --
234     Open C_Sel1;
235     Fetch C_Sel1 Into p_rec.case_group_id;
236     Close C_Sel1;
237   End If;
238   --
239   hr_utility.set_location(' Leaving:'||l_proc, 10);
240 End pre_insert;
241 --
242 -- ----------------------------------------------------------------------------
243 -- |-----------------------------< post_insert >------------------------------|
244 -- ----------------------------------------------------------------------------
245 -- {Start Of Comments}
246 --
247 -- Description:
248 --   This private procedure contains any processing which is required after
249 --   the insert dml.
250 --
251 -- Prerequisites:
252 --   This is an internal procedure which is called from the ins procedure.
253 --
254 -- In Parameters:
255 --   A Pl/Sql record structre.
256 --
257 -- Post Success:
258 --   Processing continues.
259 --
260 -- Post Failure:
261 --   If an error has occurred, an error message and exception will be raised
262 --   but not handled.
263 --
264 -- Developer Implementation Notes:
265 --   Any post-processing required after the insert dml is issued should be
266 --   coded within this procedure. It is important to note that any 3rd party
267 --   maintenance should be reviewed before placing in this procedure.
268 --
269 -- Access Status:
270 --   Internal Row Handler Use Only.
271 --
272 -- {End Of Comments}
273 -- ----------------------------------------------------------------------------
274 Procedure post_insert
275   (p_effective_date               in date
276   ,p_rec                          in pqh_cgn_shd.g_rec_type
277   ) is
278 --
279   l_proc  varchar2(72) := g_package||'post_insert';
280 --
281 Begin
282   hr_utility.set_location('Entering:'||l_proc, 5);
283   begin
284     --
285     pqh_cgn_rki.after_insert
286       (p_effective_date              => p_effective_date
287       ,p_case_group_id
288       => p_rec.case_group_id
289       ,p_case_group_number
290       => p_rec.case_group_number
291       ,p_description
292       => p_rec.description
293       ,p_advanced_pay_grade
294       => p_rec.advanced_pay_grade
295       ,p_entries_in_minute
296       => p_rec.entries_in_minute
297       ,p_period_of_prob_advmnt
298       => p_rec.period_of_prob_advmnt
299       ,p_period_of_time_advmnt
300       => p_rec.period_of_time_advmnt
301       ,p_advancement_to
302       => p_rec.advancement_to
303       ,p_object_version_number
304       => p_rec.object_version_number
305       ,p_advancement_additional_pyt
306       => p_rec.advancement_additional_pyt
307       ,p_time_advanced_pay_grade
308       => p_rec.time_advanced_pay_grade
309       ,p_time_advancement_to
310       => p_rec.time_advancement_to
311       ,p_business_group_id
312       => p_rec.business_group_id
313       ,p_time_advn_units
314       => p_rec.time_advn_units
315       ,p_prob_advn_units
316       => p_rec.prob_advn_units
317       ,p_sub_csgrp_description
318       => p_rec.sub_csgrp_description
319       );
320     --
321   exception
322     --
323     when hr_api.cannot_find_prog_unit then
324       --
325       hr_api.cannot_find_prog_unit_error
326         (p_module_name => 'PQH_DE_CASE_GROUPS'
327         ,p_hook_type   => 'AI');
328       --
329   end;
330   --
331   hr_utility.set_location(' Leaving:'||l_proc, 10);
332 End post_insert;
333 --
334 -- ----------------------------------------------------------------------------
335 -- |---------------------------------< ins >----------------------------------|
336 -- ----------------------------------------------------------------------------
337 Procedure ins
338   (p_effective_date               in date
339   ,p_rec                          in out nocopy pqh_cgn_shd.g_rec_type
340   ) is
341 --
342   l_proc  varchar2(72) := g_package||'ins';
343 --
344 Begin
345   hr_utility.set_location('Entering:'||l_proc, 5);
346   --
347   -- Call the supporting insert validate operations
348   --
349   pqh_cgn_bus.insert_validate
350      (p_effective_date
351      ,p_rec
352      );
353   --
354   -- Call to raise any errors on multi-message list
355   hr_multi_message.end_validation_set;
356   --
357   -- Call the supporting pre-insert operation
358   --
359   pqh_cgn_ins.pre_insert(p_rec);
360   --
361   -- Insert the row
362   --
363   pqh_cgn_ins.insert_dml(p_rec);
364   --
365   -- Call the supporting post-insert operation
366   --
367   pqh_cgn_ins.post_insert
368      (p_effective_date
369      ,p_rec
370      );
371   --
372   -- Call to raise any errors on multi-message list
373   hr_multi_message.end_validation_set;
374   --
375   hr_utility.set_location('Leaving:'||l_proc, 20);
376 end ins;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------------< ins >----------------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure ins
382   (p_effective_date               in     date
383   ,p_case_group_number              in     varchar2
384   ,p_description                    in     varchar2
385   ,p_advanced_pay_grade             in     number   default null
386   ,p_entries_in_minute              in     varchar2 default null
387   ,p_period_of_prob_advmnt          in     number   default null
388   ,p_period_of_time_advmnt          in     number   default null
389   ,p_advancement_to                 in     number   default null
390   ,p_advancement_additional_pyt     in     number   default null
391   ,p_time_advanced_pay_grade        in     number   default null
392   ,p_time_advancement_to            in     number   default null
393   ,p_business_group_id              in     number   default null
394   ,p_time_advn_units                in     varchar2 default null
395   ,p_prob_advn_units                in     varchar2 default null
396   ,p_sub_csgrp_description          in     varchar2 default null
397   ,p_case_group_id                     out nocopy number
398   ,p_object_version_number             out nocopy number
399   ) is
400 --
401   l_rec   pqh_cgn_shd.g_rec_type;
402   l_proc  varchar2(72) := g_package||'ins';
403 --
404 Begin
405   hr_utility.set_location('Entering:'||l_proc, 5);
406   --
407   -- Call conversion function to turn arguments into the
408   -- p_rec structure.
409   --
410   l_rec :=
411   pqh_cgn_shd.convert_args
412     (null
413     ,p_case_group_number
414     ,p_description
415     ,p_advanced_pay_grade
416     ,p_entries_in_minute
417     ,p_period_of_prob_advmnt
418     ,p_period_of_time_advmnt
419     ,p_advancement_to
420     ,null
421     ,p_advancement_additional_pyt
422     ,p_time_advanced_pay_grade
423     ,p_time_advancement_to
424     ,p_business_group_id
425     ,p_time_advn_units
426     ,p_prob_advn_units
427     ,p_sub_csgrp_description
428     );
429   --
430   -- Having converted the arguments into the pqh_cgn_rec
431   -- plsql record structure we call the corresponding record business process.
432   --
433   pqh_cgn_ins.ins
434      (p_effective_date
435      ,l_rec
436      );
437   --
438   -- As the primary key argument(s)
439   -- are specified as an OUT's we must set these values.
440   --
441   p_case_group_id := l_rec.case_group_id;
442   p_object_version_number := l_rec.object_version_number;
443   --
444   hr_utility.set_location(' Leaving:'||l_proc, 10);
445 End ins;
446 --
447 end pqh_cgn_ins;