DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_VLP_INS

Source


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