DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_PDC_UPD

Source


1 Package Body ghr_pdc_upd as
2 /* $Header: ghpdcrhi.pkb 115.6 1999/11/09 22:43:48 pkm ship    $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ghr_pdc_upd.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< update_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml update logic. The processing of
17 --   this procedure is:
18 --   1) Increment the object_version_number by 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To set and unset the g_api_dml status as required (as we are about to
21 --      perform dml).
22 --   3) To update the specified row in the schema using the primary key in
23 --      the predicates.
24 --   4) To trap any constraint violations that may have occurred.
25 --   5) To raise any other errors.
26 --
27 -- Prerequisites:
28 --   This is an internal private procedure which must be called from the upd
29 --   procedure.
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structure.
33 --
34 -- Post Success:
35 --   The specified row will be updated in the schema.
36 --
37 -- Post Failure:
38 --   On the update dml failure it is important to note that we always reset the
39 --   g_api_dml status to false.
40 --   If a check, unique or parent integrity constraint violation is raised the
41 --   constraint_error procedure will be called.
42 --   If any other error is reported, the error will be raised after the
43 --   g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 --   The update 'set' attribute list should be modified if any of your
47 --   attributes are not updateable.
48 --
49 -- Access Status:
50 --   Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out ghr_pdc_shd.g_rec_type) is
55 --
56   l_proc  varchar2(72) := g_package||'update_dml';
57 --
58 Begin
59   hr_utility.set_location('Entering:'||l_proc, 5);
60   --
61   -- Increment the object version
62   --
63   p_rec.object_version_number := p_rec.object_version_number + 1;
64   --
65   --ghr_pdc_shd.g_api_dml := true;  -- Set the api dml status
66   --
67   -- Update the ghr_pd_classifications Row
68   --
69   update ghr_pd_classifications
70   set
71   class_grade_by                    = p_rec.class_grade_by,
72   official_title                    = p_rec.official_title,
73   pay_plan                          = p_rec.pay_plan,
74   occupational_code                 = p_rec.occupational_code,
75   grade_level                       = p_rec.grade_level,
76   object_version_number             = p_rec.object_version_number
77   where pd_classification_id = p_rec.pd_classification_id;
78   --
79   --ghr_pdc_shd.g_api_dml := false;   -- Unset the api dml status
80   --
81   hr_utility.set_location(' Leaving:'||l_proc, 10);
82 --
83 Exception
84   When hr_api.check_integrity_violated Then
85     -- A check constraint has been violated
86     --ghr_pdc_shd.g_api_dml := false;   -- Unset the api dml status
87     ghr_pdc_shd.constraint_error
88       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
89   When hr_api.parent_integrity_violated Then
90     -- Parent integrity has been violated
91     --ghr_pdc_shd.g_api_dml := false;   -- Unset the api dml status
92     ghr_pdc_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.unique_integrity_violated Then
95     -- Unique integrity has been violated
96     --ghr_pdc_shd.g_api_dml := false;   -- Unset the api dml status
97     ghr_pdc_shd.constraint_error
98       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
99   When Others Then
100     --ghr_pdc_shd.g_api_dml := false;   -- Unset the api dml status
101     Raise;
102 End update_dml;
103 --
104 -- ----------------------------------------------------------------------------
105 -- |------------------------------< pre_update >------------------------------|
106 -- ----------------------------------------------------------------------------
107 -- {Start Of Comments}
108 --
109 -- Description:
110 --   This private procedure contains any processing which is required before
111 --   the update dml.
112 --
113 -- Prerequisites:
114 --   This is an internal procedure which is called from the upd procedure.
115 --
116 -- In Parameters:
117 --   A Pl/Sql record structure.
118 --
119 -- Post Success:
120 --   Processing continues.
121 --
122 -- Post Failure:
123 --   If an error has occurred, an error message and exception will be raised
124 --   but not handled.
125 --
126 -- Developer Implementation Notes:
127 --   Any pre-processing required before the update dml is issued should be
128 --   coded within this procedure. It is important to note that any 3rd party
129 --   maintenance should be reviewed before placing in this procedure.
130 --
131 -- Access Status:
132 --   Internal Row Handler Use Only.
133 --
134 -- {End Of Comments}
135 -- ----------------------------------------------------------------------------
136 Procedure pre_update(p_rec in ghr_pdc_shd.g_rec_type) is
137 --
138   l_proc  varchar2(72) := g_package||'pre_update';
139 --
140 Begin
141   hr_utility.set_location('Entering:'||l_proc, 5);
142   --
143   hr_utility.set_location(' Leaving:'||l_proc, 10);
144 End pre_update;
145 --
146 -- ----------------------------------------------------------------------------
147 -- |-----------------------------< post_update >------------------------------|
148 -- ----------------------------------------------------------------------------
149 -- {Start Of Comments}
150 --
151 -- Description:
152 --   This private procedure contains any processing which is required after the
153 --   update dml.
154 --
155 -- Prerequisites:
156 --   This is an internal procedure which is called from the upd procedure.
157 --
158 -- In Parameters:
159 --   A Pl/Sql record structure.
160 --
161 -- Post Success:
162 --   Processing continues.
163 --
164 -- Post Failure:
165 --   If an error has occurred, an error message and exception will be raised
166 --   but not handled.
167 --
168 -- Developer Implementation Notes:
169 --   Any post-processing required after the update dml is issued should be
170 --   coded within this procedure. It is important to note that any 3rd party
171 --   maintenance should be reviewed before placing in this procedure.
172 --
173 -- Access Status:
174 --   Internal Row Handler Use Only.
175 --
176 -- {End Of Comments}
177 -- ----------------------------------------------------------------------------
178 Procedure post_update(p_rec in ghr_pdc_shd.g_rec_type) is
179 --
180   l_proc  varchar2(72) := g_package||'post_update';
181 --
182 Begin
183   hr_utility.set_location('Entering:'||l_proc, 5);
184   --
185   -- This is a hook point and the user hook for post_update is called here.
186   --
187   begin
188      ghr_pdc_rku.after_update	(
189       p_pd_classification_id      =>     p_rec.pd_classification_id,
190       p_position_description_id   =>     p_rec.position_description_id,
191       p_class_grade_by            =>     p_rec.class_grade_by,
192       p_official_title            =>     p_rec.official_title,
193       p_pay_plan                  =>     p_rec.pay_plan,
194       p_occupational_code         =>     p_rec.occupational_code,
195       p_grade_level               =>     p_rec.grade_level,
196       p_object_version_number     =>     p_rec.object_version_number,
197       p_position_description_id_o =>     ghr_pdc_shd.g_old_rec.position_description_id,
198       p_class_grade_by_o          =>     ghr_pdc_shd.g_old_rec.class_grade_by,
199       p_official_title_o          =>     ghr_pdc_shd.g_old_rec.official_title,
200       p_pay_plan_o                =>     ghr_pdc_shd.g_old_rec.pay_plan,
201       p_occupational_code_o       =>     ghr_pdc_shd.g_old_rec.occupational_code,
202       p_grade_level_o             =>     ghr_pdc_shd.g_old_rec.grade_level,
203       p_object_version_number_o   =>     ghr_pdc_shd.g_old_rec.object_version_number
204       );
205 
206   exception
207         when hr_api.cannot_find_prog_unit then
208              hr_api.cannot_find_prog_unit_error
209 		 (	 p_module_name => 'GHR_PD_CLASSIFICATIONS'
210 			,p_hook_type   => 'AU'
211 	        );
212   end;
213   -- End of API User Hook for post_update.
214   --
215   hr_utility.set_location(' Leaving:'||l_proc, 10);
216 End post_update;
217 --
218 -- ----------------------------------------------------------------------------
219 -- |-----------------------------< convert_defs >-----------------------------|
220 -- ----------------------------------------------------------------------------
221 -- {Start Of Comments}
222 --
223 -- Description:
224 --   The Convert_Defs procedure has one very important function:
225 --   It must return the record structure for the row with all system defaulted
226 --   values converted into its corresponding parameter value for update. When
227 --   we attempt to update a row through the Upd process , certain
228 --   parameters can be defaulted which enables flexibility in the calling of
229 --   the upd process (e.g. only attributes which need to be updated need to be
230 --   specified). For the upd process to determine which attributes
231 --   have NOT been specified we need to check if the parameter has a reserved
232 --   system default value. Therefore, for all parameters which have a
233 --   corresponding reserved system default mechanism specified we need to
234 --   check if a system default is being used. If a system default is being
235 --   used then we convert the defaulted value into its corresponding attribute
236 --   value held in the g_old_rec data structure.
237 --
238 -- Prerequisites:
239 --   This private function can only be called from the upd process.
240 --
241 -- In Parameters:
242 --   A Pl/Sql record structure.
243 --
244 -- Post Success:
245 --   The record structure will be returned with all system defaulted parameter
246 --   values converted into its current row attribute value.
247 --
248 -- Post Failure:
249 --   No direct error handling is required within this function. Any possible
250 --   errors within this procedure will be a PL/SQL value error due to conversion
251 
252 --   of datatypes or data lengths.
253 --
254 -- Developer Implementation Notes:
255 --   None.
256 --
257 -- Access Status:
258 --   Internal Row Handler Use Only.
259 --
260 -- {End Of Comments}
261 -- ----------------------------------------------------------------------------
262 Procedure convert_defs(p_rec in out ghr_pdc_shd.g_rec_type) is
263 --
264   l_proc  varchar2(72) := g_package||'convert_defs';
265 --
266 Begin
267   --
268   hr_utility.set_location('Entering:'||l_proc, 5);
269   --
270   -- We must now examine each argument value in the
271   -- p_rec plsql record structure
272   -- to see if a system default is being used. If a system default
273   -- is being used then we must set to the 'current' argument value.
274   --
275   If (p_rec.position_description_id = hr_api.g_number) then
276     p_rec.position_description_id :=
277     ghr_pdc_shd.g_old_rec.position_description_id;
278   End If;
279   If (p_rec.class_grade_by = hr_api.g_varchar2) then
280     p_rec.class_grade_by :=
281     ghr_pdc_shd.g_old_rec.class_grade_by;
282   End If;
283   If (p_rec.official_title = hr_api.g_varchar2) then
284     p_rec.official_title :=
285     ghr_pdc_shd.g_old_rec.official_title;
286   End If;
287   If (p_rec.pay_plan = hr_api.g_varchar2) then
288     p_rec.pay_plan :=
289     ghr_pdc_shd.g_old_rec.pay_plan;
290   End If;
291   If (p_rec.occupational_code = hr_api.g_varchar2) then
292     p_rec.occupational_code :=
293     ghr_pdc_shd.g_old_rec.occupational_code;
294   End If;
295   If (p_rec.grade_level = hr_api.g_varchar2) then
296     p_rec.grade_level :=
297     ghr_pdc_shd.g_old_rec.grade_level;
298   End If;
299 
300   --
301   hr_utility.set_location(' Leaving:'||l_proc, 10);
302 --
303 End convert_defs;
304 --
305 -- ----------------------------------------------------------------------------
306 -- |---------------------------------< upd >----------------------------------|
307 -- ----------------------------------------------------------------------------
308 Procedure upd
309   (
310   p_rec        in out ghr_pdc_shd.g_rec_type
311   ) is
312 --
313   l_proc  varchar2(72) := g_package||'upd';
314 --
315 Begin
316   hr_utility.set_location('Entering:'||l_proc, 5);
317   --
318   -- We must lock the row which we need to update.
319   --
320   ghr_pdc_shd.lck
321 	(
322 	p_rec.pd_classification_id,
323 	p_rec.object_version_number
324 	);
325   --
326   -- 1. During an update system defaults are used to determine if
327   --    arguments have been defaulted or not. We must therefore
328   --    derive the full record structure values to be updated.
329   --
330   -- 2. Call the supporting update validate operations.
331   --
332   convert_defs(p_rec);
333   ghr_pdc_bus.update_validate(p_rec);
334   --
335   -- Call the supporting pre-update operation
336   --
337   pre_update(p_rec);
338   --
339   -- Update the row.
340   --
341   update_dml(p_rec);
342   --
343   -- Call the supporting post-update operation
344   --
345   post_update(p_rec);
346 End upd;
347 --
348 -- ----------------------------------------------------------------------------
349 -- |---------------------------------< upd >----------------------------------|
350 -- ----------------------------------------------------------------------------
351 Procedure upd
352   (
353   p_pd_classification_id         in number,
354   p_position_description_id      in number           default hr_api.g_number,
355   p_class_grade_by               in varchar2         default hr_api.g_varchar2,
356   p_official_title               in varchar2         default hr_api.g_varchar2,
357   p_pay_plan                     in varchar2         default hr_api.g_varchar2,
358   p_occupational_code            in varchar2         default hr_api.g_varchar2,
359   p_grade_level                  in varchar2         default hr_api.g_varchar2,
360   p_object_version_number        in out number
361   ) is
362 --
363   l_rec	  ghr_pdc_shd.g_rec_type;
364   l_proc  varchar2(72) := g_package||'upd';
365 --
366 Begin
367   hr_utility.set_location('Entering:'||l_proc, 5);
368   hr_utility.set_location('pdc id:' || to_char(p_pd_classification_id) ||l_proc, 5);
369   hr_utility.set_location('pd id:' || to_char(p_position_description_id)||l_proc, 5);
370   hr_utility.set_location('ovn :' || to_char(p_position_description_id)||l_proc, 5);
371   --
372   -- Call conversion function to turn arguments into the
373   -- l_rec structure.
374   --
375   l_rec :=
376   ghr_pdc_shd.convert_args
377   (
378   p_pd_classification_id,
379   p_position_description_id,
380   p_class_grade_by,
381   p_official_title,
382   p_pay_plan,
383   p_occupational_code,
384   p_grade_level,
385   p_object_version_number
386   );
387   --
388   -- Having converted the arguments into the
389   -- plsql record structure we call the corresponding record
390   -- business process.
391   --
392   upd(l_rec);
393   p_object_version_number := l_rec.object_version_number;
394   --
395   hr_utility.set_location(' Leaving:'||l_proc, 10);
396 End upd;
397 --
398 end ghr_pdc_upd;