1 Package Body hr_ppu_upd as
2 /* $Header: hrppurhi.pkb 115.1 99/07/17 05:36:57 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_ppu_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 -- Pre Conditions:
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 structre.
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 Table Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out hr_ppu_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 hr_ppu_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Update the hr_pattern_purpose_usages Row
68 --
69 update hr_pattern_purpose_usages
70 set
71 purpose_usage_id = p_rec.purpose_usage_id,
72 entity_name = p_rec.entity_name,
73 pattern_purpose = p_rec.pattern_purpose,
74 hierarchy_level = p_rec.hierarchy_level,
75 object_version_number = p_rec.object_version_number
76 where purpose_usage_id = p_rec.purpose_usage_id;
77 --
78 hr_ppu_shd.g_api_dml := false; -- Unset the api dml status
79 --
80 hr_utility.set_location(' Leaving:'||l_proc, 10);
81 --
82 Exception
83 When hr_api.check_integrity_violated Then
84 -- A check constraint has been violated
85 hr_ppu_shd.g_api_dml := false; -- Unset the api dml status
86 hr_ppu_shd.constraint_error
87 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
88 When hr_api.parent_integrity_violated Then
89 -- Parent integrity has been violated
90 hr_ppu_shd.g_api_dml := false; -- Unset the api dml status
91 hr_ppu_shd.constraint_error
92 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93 When hr_api.unique_integrity_violated Then
94 -- Unique integrity has been violated
95 hr_ppu_shd.g_api_dml := false; -- Unset the api dml status
96 hr_ppu_shd.constraint_error
97 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98 When Others Then
99 hr_ppu_shd.g_api_dml := false; -- Unset the api dml status
100 Raise;
101 End update_dml;
102 --
103 -- ----------------------------------------------------------------------------
104 -- |------------------------------< pre_update >------------------------------|
105 -- ----------------------------------------------------------------------------
106 -- {Start Of Comments}
107 --
108 -- Description:
109 -- This private procedure contains any processing which is required before
110 -- the update dml.
111 --
112 -- Pre Conditions:
113 -- This is an internal procedure which is called from the upd procedure.
114 --
115 -- In Parameters:
116 -- A Pl/Sql record structre.
117 --
118 -- Post Success:
119 -- Processing continues.
120 --
121 -- Post Failure:
122 -- If an error has occurred, an error message and exception will be raised
123 -- but not handled.
124 --
125 -- Developer Implementation Notes:
126 -- Any pre-processing required before the update dml is issued should be
127 -- coded within this procedure. It is important to note that any 3rd party
128 -- maintenance should be reviewed before placing in this procedure.
129 --
130 -- Access Status:
131 -- Internal Table Handler Use Only.
132 --
133 -- {End Of Comments}
134 -- ----------------------------------------------------------------------------
135 Procedure pre_update(p_rec in hr_ppu_shd.g_rec_type) is
136 --
137 l_proc varchar2(72) := g_package||'pre_update';
138 --
139 Begin
140 hr_utility.set_location('Entering:'||l_proc, 5);
141 --
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 -- Pre Conditions:
156 -- This is an internal procedure which is called from the upd procedure.
157 --
158 -- In Parameters:
159 -- A Pl/Sql record structre.
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 Table Handler Use Only.
175 --
176 -- {End Of Comments}
177 -- ----------------------------------------------------------------------------
178 Procedure post_update(p_rec in hr_ppu_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 --
186 --
187 hr_utility.set_location(' Leaving:'||l_proc, 10);
188 End post_update;
189 --
190 -- ----------------------------------------------------------------------------
191 -- |-----------------------------< convert_defs >-----------------------------|
192 -- ----------------------------------------------------------------------------
193 -- {Start Of Comments}
194 --
195 -- Description:
196 -- The Convert_Defs procedure has one very important function:
197 -- It must return the record structure for the row with all system defaulted
198 -- values converted into its corresponding parameter value for update. When
199 -- we attempt to update a row through the Upd process , certain
200 -- parameters can be defaulted which enables flexibility in the calling of
201 -- the upd process (e.g. only attributes which need to be updated need to be
202 -- specified). For the upd process to determine which attributes
203 -- have NOT been specified we need to check if the parameter has a reserved
204 -- system default value. Therefore, for all parameters which have a
205 -- corresponding reserved system default mechanism specified we need to
206 -- check if a system default is being used. If a system default is being
207 -- used then we convert the defaulted value into its corresponding attribute
208 -- value held in the g_old_rec data structure.
209 --
210 -- Pre Conditions:
211 -- This private function can only be called from the upd process.
212 --
213 -- In Parameters:
214 -- A Pl/Sql record structre.
215 --
216 -- Post Success:
217 -- The record structure will be returned with all system defaulted parameter
218 -- values converted into its current row attribute value.
219 --
220 -- Post Failure:
221 -- No direct error handling is required within this function. Any possible
222 -- errors within this procedure will be a PL/SQL value error due to conversion
223
224 -- of datatypes or data lengths.
225 --
226 -- Developer Implementation Notes:
227 -- None.
228 --
229 -- Access Status:
230 -- Internal Table Handler Use Only.
231 --
232 -- {End Of Comments}
233 -- ----------------------------------------------------------------------------
234 Procedure convert_defs(p_rec in out hr_ppu_shd.g_rec_type) is
235 --
236 l_proc varchar2(72) := g_package||'convert_defs';
237 --
238 Begin
239 --
240 hr_utility.set_location('Entering:'||l_proc, 5);
241 --
242 -- We must now examine each argument value in the
243 -- p_rec plsql record structure
244 -- to see if a system default is being used. If a system default
245 -- is being used then we must set to the 'current' argument value.
246 --
247 If (p_rec.entity_name = hr_api.g_varchar2) then
248 p_rec.entity_name :=
249 hr_ppu_shd.g_old_rec.entity_name;
250 End If;
251 If (p_rec.pattern_purpose = hr_api.g_varchar2) then
252 p_rec.pattern_purpose :=
253 hr_ppu_shd.g_old_rec.pattern_purpose;
254 End If;
255 If (p_rec.hierarchy_level = hr_api.g_number) then
256 p_rec.hierarchy_level :=
257 hr_ppu_shd.g_old_rec.hierarchy_level;
258 End If;
259
260 --
261 hr_utility.set_location(' Leaving:'||l_proc, 10);
262 --
263 End convert_defs;
264 --
265 -- ----------------------------------------------------------------------------
266 -- |---------------------------------< upd >----------------------------------|
267 -- ----------------------------------------------------------------------------
268 Procedure upd
269 (
270 p_rec in out hr_ppu_shd.g_rec_type,
271 p_validate in boolean default false
272 ) is
273 --
274 l_proc varchar2(72) := g_package||'upd';
275 --
276 Begin
277 hr_utility.set_location('Entering:'||l_proc, 5);
278 --
279 -- Determine if the business process is to be validated.
280 --
281 If p_validate then
282 --
283 -- Issue the savepoint.
284 --
285 SAVEPOINT upd_hr_ppu;
286 End If;
287 --
288 -- We must lock the row which we need to update.
289 --
290 hr_ppu_shd.lck
291 (
292 p_rec.purpose_usage_id,
293 p_rec.object_version_number
294 );
295 --
296 -- 1. During an update system defaults are used to determine if
297 -- arguments have been defaulted or not. We must therefore
298 -- derive the full record structure values to be updated.
299 --
300 -- 2. Call the supporting update validate operations.
301 --
302 convert_defs(p_rec);
303 hr_ppu_bus.update_validate(p_rec);
304 --
305 -- Call the supporting pre-update operation
306 --
307 pre_update(p_rec);
308 --
309 -- Update the row.
310 --
311 update_dml(p_rec);
312 --
313 -- Call the supporting post-update operation
314 --
315 post_update(p_rec);
316 --
317 -- If we are validating then raise the Validate_Enabled exception
318 --
319 If p_validate then
320 Raise HR_Api.Validate_Enabled;
321 End If;
322 --
323 hr_utility.set_location(' Leaving:'||l_proc, 10);
324 Exception
325 When HR_Api.Validate_Enabled Then
326 --
327 -- As the Validate_Enabled exception has been raised
328 -- we must rollback to the savepoint
329 --
330 ROLLBACK TO upd_hr_ppu;
331 End upd;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |---------------------------------< upd >----------------------------------|
335 -- ----------------------------------------------------------------------------
336 Procedure upd
337 (
338 p_purpose_usage_id in number,
339 p_entity_name in varchar2 default hr_api.g_varchar2,
340 p_pattern_purpose in varchar2 default hr_api.g_varchar2,
341 p_hierarchy_level in number default hr_api.g_number,
342 p_object_version_number in out number,
343 p_validate in boolean default false
344 ) is
345 --
346 l_rec hr_ppu_shd.g_rec_type;
347 l_proc varchar2(72) := g_package||'upd';
348 --
349 Begin
350 hr_utility.set_location('Entering:'||l_proc, 5);
351 --
352 -- Call conversion function to turn arguments into the
353 -- l_rec structure.
354 --
355 l_rec :=
356 hr_ppu_shd.convert_args
357 (
358 p_purpose_usage_id,
359 p_entity_name,
360 p_pattern_purpose,
361 p_hierarchy_level,
362 p_object_version_number
363 );
364 --
365 -- Having converted the arguments into the
366 -- plsql record structure we call the corresponding record
367 -- business process.
368 --
369 upd(l_rec, p_validate);
370 p_object_version_number := l_rec.object_version_number;
371 --
372 hr_utility.set_location(' Leaving:'||l_proc, 10);
373 End upd;
374 --
375 end hr_ppu_upd;