DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_VER_INS

Source


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