1 Package Body per_za_tra_upd as
2 /* $Header: pezatrup.pkb 115.1 2002/12/05 06:52:45 nsugavan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_za_tra_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 nocopy per_za_tra_shd.g_za_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 --
64 per_za_tra_shd.g_api_dml := true; -- Set the api dml status
65 --
66 -- Update the per_za_assessments Row
67 --
68 update per_za_training
69 set
70 level_id = p_rec.level_id,
71 person_id = p_rec.person_id,
72 field_of_learning = p_rec.field_of_learning,
73 course = p_rec.course,
74 sub_field = p_rec.sub_field,
75 credit = p_rec.credit,
76 notional_hours = p_rec.notional_hours,
77 registration_date = p_rec.registration_date,
78 registration_number = p_rec.registration_number
79 where training_id = p_rec.training_id;
80
81 --
82 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
83 --
84 hr_utility.set_location(' Leaving:'||l_proc, 10);
85 --
86 Exception
87 When hr_api.check_integrity_violated Then
88 -- A check constraint has been violated
89 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
90 per_za_tra_shd.constraint_error
91 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
92 When hr_api.parent_integrity_violated Then
93 -- Parent integrity has been violated
94 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
95 per_za_tra_shd.constraint_error
96 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
97 When hr_api.unique_integrity_violated Then
98 -- Unique integrity has been violated
99 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
100 per_za_tra_shd.constraint_error
101 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
102 When Others Then
103 per_za_tra_shd.g_api_dml := false; -- Unset the api dml status
104 Raise;
105 End update_dml;
106 --
107 -- ----------------------------------------------------------------------------
108 -- |------------------------------< pre_update >------------------------------|
109 -- ----------------------------------------------------------------------------
110 -- {Start Of Comments}
111 --
112 -- Description:
113 -- This private procedure contains any processing which is required before
114 -- the update dml.
115 --
116 -- Pre Conditions:
117 -- This is an internal procedure which is called from the upd procedure.
118 --
119 -- In Parameters:
120 -- A Pl/Sql record structre.
121 --
122 -- Post Success:
123 -- Processing continues.
124 --
125 -- Post Failure:
126 -- If an error has occurred, an error message and exception will be raised
127 -- but not handled.
128 --
129 -- Developer Implementation Notes:
130 -- Any pre-processing required before the update dml is issued should be
131 -- coded within this procedure. It is important to note that any 3rd party
132 -- maintenance should be reviewed before placing in this procedure.
133 --
134 -- Access Status:
135 -- Internal Table Handler Use Only.
136 --
137 -- {End Of Comments}
138 -- ----------------------------------------------------------------------------
139 Procedure pre_update(p_rec in per_za_tra_shd.g_za_rec_type) is
140 --
141 l_proc varchar2(72) := g_package||'pre_update';
142 --
143 Begin
144 hr_utility.set_location('Entering:'||l_proc, 5);
145 --
146 hr_utility.set_location(' Leaving:'||l_proc, 10);
147 End pre_update;
148 --
149 -- ----------------------------------------------------------------------------
150 -- |-----------------------------< post_update >------------------------------|
151 -- ----------------------------------------------------------------------------
152 -- {Start Of Comments}
153 --
154 -- Description:
155 -- This private procedure contains any processing which is required after the
156 -- update dml.
157 --
158 -- Pre Conditions:
159 -- This is an internal procedure which is called from the upd procedure.
160 --
161 -- In Parameters:
162 -- A Pl/Sql record structre.
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 post-processing required after the update dml is issued should be
173 -- coded within this procedure. It is important to note that any 3rd party
174 -- maintenance should be reviewed before placing in this procedure.
175 --
176 -- Access Status:
177 -- Internal Table Handler Use Only.
178 --
179 -- {End Of Comments}
180 -- ----------------------------------------------------------------------------
181 Procedure post_update(p_rec in per_za_tra_shd.g_za_rec_type) is
182 --
183 l_proc varchar2(72) := g_package||'post_update';
184 --
185 Begin
186 hr_utility.set_location('Entering:'||l_proc, 5);
187 --
188 hr_utility.set_location(' Leaving:'||l_proc, 10);
189 End post_update;
190 --
191 -- ----------------------------------------------------------------------------
192 -- |---------------------------------< upd >----------------------------------|
193 -- ----------------------------------------------------------------------------
194 Procedure upd
195 (
196 p_rec in out nocopy per_za_tra_shd.g_za_rec_type,
197 p_validate in boolean default false
198 ) is
199 --
200 l_proc varchar2(72) := g_package||'upd';
201 --
202 Begin
203 hr_utility.set_location('Entering:'||l_proc, 5);
204 --
205 -- Determine if the business process is to be validated.
206 --
207 If p_validate then
208 --
209 -- Issue the savepoint.
210 --
211 SAVEPOINT upd_tra;
212 End If;
213 --
214 -- We must lock the row which we need to update.
215 --
216 per_za_tra_shd.lck
217 (
218 p_rec.training_id,
219 p_rec.person_id
220 );
221 --
222 -- 1. During an update system defaults are used to determine if
223 -- arguments have been defaulted or not. We must therefore
224 -- derive the full record structure values to be updated.
225 --
226 -- 2. Call the supporting update validate operations.
227 --
228 -- convert_defs(p_rec);
229 -- per_za_tra_bus.update_validate(p_rec,p_effective_date);
230 --
231 -- Call the supporting pre-update operation
232 --
233 pre_update(p_rec);
234 --
235 -- Update the row.
236 --
237 update_dml(p_rec);
238 --
239 -- Call the supporting post-update operation
240 --
241 post_update(p_rec);
242 --
243 -- If we are validating then raise the Validate_Enabled exception
244 --
245 If p_validate then
246 Raise HR_Api.Validate_Enabled;
247 End If;
248 --
249 hr_utility.set_location(' Leaving:'||l_proc, 10);
250 Exception
251 When HR_Api.Validate_Enabled Then
252 --
253 -- As the Validate_Enabled exception has been raised
254 -- we must rollback to the savepoint
255 --
256 ROLLBACK TO upd_tra;
257 End upd;
258 --
259 -- ----------------------------------------------------------------------------
260 -- |---------------------------------< upd >----------------------------------|
261 -- ----------------------------------------------------------------------------
262 Procedure upd
263 (
264 P_TRAINING_ID IN NUMBER,
265 P_LEVEL_ID IN NUMBER default null,
266 P_PERSON_ID IN NUMBER,
267 P_FIELD_OF_LEARNING IN VARCHAR2 default null,
268 P_COURSE IN VARCHAR2 default null,
269 P_SUB_FIELD IN VARCHAR2 default null,
270 P_CREDIT IN NUMBER default null,
271 P_NOTIONAL_HOURS IN NUMBER default null,
272 P_REGISTRATION_DATE IN DATE default null,
273 P_REGISTRATION_NUMBER IN VARCHAR2 default null,
274 p_validate in boolean default false
275 ) is
276 --
277 l_rec per_za_tra_shd.g_za_rec_type;
278 l_proc varchar2(72) := g_package||'upd';
279 --
280 Begin
281 hr_utility.set_location('Entering:'||l_proc, 5);
282 --
283 -- Call conversion function to turn arguments into the
284 -- l_rec structure.
285 --
286 l_rec :=
287 per_za_tra_shd.convert_args
288 (
289 P_TRAINING_ID,
290 P_LEVEL_ID ,
291 P_PERSON_ID,
292 P_FIELD_OF_LEARNING ,
293 P_COURSE ,
294 P_SUB_FIELD ,
295 P_CREDIT ,
296 P_NOTIONAL_HOURS,
297 P_REGISTRATION_DATE ,
298 P_REGISTRATION_NUMBER
299 );
300 --
301 -- Having converted the arguments into the
302 -- plsql record structure we call the corresponding record
303 -- business process.
304 --
305 upd(l_rec, p_validate);
306 --
307 hr_utility.set_location(' Leaving:'||l_proc, 10);
308 End upd;
309 --
310 end per_za_tra_upd;