1 Package Body hr_qsn_upd as
2 /* $Header: hrqsnrhi.pkb 120.4.12010000.3 2008/11/05 09:57:56 rsykam ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_qsn_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 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 Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure update_dml(p_rec in out nocopy hr_qsn_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 -- Update the hr_questionnaires Row
66 --
67 update hr_questionnaires quest
68 set
69 quest.questionnaire_template_id = p_rec.questionnaire_template_id,
70 quest.text = p_rec.text,
71 quest.available_flag = p_rec.available_flag,
72 quest.business_group_id = p_rec.business_group_id,
73 quest.object_version_number = p_rec.object_version_number
74 where quest.questionnaire_template_id = p_rec.questionnaire_template_id;
75 --
76 hr_utility.set_location(' Leaving:'||l_proc, 10);
77 --
78 Exception
79 When hr_api.check_integrity_violated Then
80 -- A check constraint has been violated
81 hr_qsn_shd.constraint_error
82 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
83 When hr_api.parent_integrity_violated Then
84 -- Parent integrity has been violated
85 hr_qsn_shd.constraint_error
86 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
87 When hr_api.unique_integrity_violated Then
88 -- Unique integrity has been violated
89 hr_qsn_shd.constraint_error
90 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
91 When Others Then
92 Raise;
93 End update_dml;
94 --
95 -- ----------------------------------------------------------------------------
96 -- |------------------------------< pre_update >------------------------------|
97 -- ----------------------------------------------------------------------------
98 -- {Start Of Comments}
99 --
100 -- Description:
101 -- This private procedure contains any processing which is required before
102 -- the update dml.
103 --
104 -- Prerequisites:
105 -- This is an internal procedure which is called from the upd procedure.
106 --
107 -- In Parameters:
108 -- A Pl/Sql record structre.
109 --
110 -- Post Success:
111 -- Processing continues.
112 --
113 -- Post Failure:
114 -- If an error has occurred, an error message and exception will be raised
115 -- but not handled.
116 --
117 -- Developer Implementation Notes:
118 -- Any pre-processing required before the update dml is issued should be
119 -- coded within this procedure. It is important to note that any 3rd party
120 -- maintenance should be reviewed before placing in this procedure.
121 --
122 -- Access Status:
123 -- Internal Row Handler Use Only.
124 --
125 -- {End Of Comments}
126 -- ----------------------------------------------------------------------------
127 Procedure pre_update(p_rec in hr_qsn_shd.g_rec_type) is
128 --
129 l_proc varchar2(72) := g_package||'pre_update';
130 --
131 Begin
132 hr_utility.set_location('Entering:'||l_proc, 5);
133 --
134 hr_utility.set_location(' Leaving:'||l_proc, 10);
135 End pre_update;
136 --
137 -- ----------------------------------------------------------------------------
138 -- |-----------------------------< post_update >------------------------------|
139 -- ----------------------------------------------------------------------------
140 -- {Start Of Comments}
141 --
142 -- Description:
143 -- This private procedure contains any processing which is required after the
144 -- update dml.
145 --
146 -- Prerequisites:
147 -- This is an internal procedure which is called from the upd procedure.
148 --
149 -- In Parameters:
150 -- A Pl/Sql record structre.
151 --
152 -- Post Success:
153 -- Processing continues.
154 --
155 -- Post Failure:
156 -- If an error has occurred, an error message and exception will be raised
157 -- but not handled.
158 --
159 -- Developer Implementation Notes:
160 -- Any post-processing required after the update dml is issued should be
161 -- coded within this procedure. It is important to note that any 3rd party
162 -- maintenance should be reviewed before placing in this procedure.
163 --
164 -- Access Status:
165 -- Internal Row Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure post_update(p_rec in hr_qsn_shd.g_rec_type
170 ,p_effective_date in date
171 ) is
172 --
173 l_proc varchar2(72) := g_package||'post_update';
174 --
175 Begin
176 hr_utility.set_location('Entering:'||l_proc, 5);
177 --
178 begin
179 hr_qsn_rku.after_update
180 (p_questionnaire_template_id => p_rec.questionnaire_template_id
181 ,p_available_flag => p_rec.available_flag
182 ,p_object_version_number => p_rec.object_version_number
183 ,p_name_o => hr_qsn_shd.g_old_rec.name
184 -- ,p_text_o => hr_qsn_shd.g_old_rec.text
185 ,p_available_flag_o
186 => hr_qsn_shd.g_old_rec.available_flag
187 ,p_business_group_id_o
188 => hr_qsn_shd.g_old_rec.business_group_id
189 ,p_object_version_number_o
190 => hr_qsn_shd.g_old_rec.object_version_number
191 ,p_effective_date => p_effective_date
192 );
193 exception
194 when hr_api.cannot_find_prog_unit then
195 hr_api.cannot_find_prog_unit_error
196 (p_module_name => 'HR_QUESTIONNAIRES'
197 ,p_hook_type => 'AU'
198 );
199 end;
200 hr_utility.set_location(' Leaving:'||l_proc, 10);
201 End post_update;
202 --
203 -- ----------------------------------------------------------------------------
204 -- |-----------------------------< convert_defs >-----------------------------|
205 -- ----------------------------------------------------------------------------
206 -- {Start Of Comments}
207 --
208 -- Description:
209 -- The Convert_Defs procedure has one very important function:
210 -- It must return the record structure for the row with all system defaulted
211 -- values converted into its corresponding parameter value for update. When
212 -- we attempt to update a row through the Upd process , certain
213 -- parameters can be defaulted which enables flexibility in the calling of
214 -- the upd process (e.g. only attributes which need to be updated need to be
215 -- specified). For the upd process to determine which attributes
216 -- have NOT been specified we need to check if the parameter has a reserved
217 -- system default value. Therefore, for all parameters which have a
218 -- corresponding reserved system default mechanism specified we need to
219 -- check if a system default is being used. If a system default is being
220 -- used then we convert the defaulted value into its corresponding attribute
221 -- value held in the g_old_rec data structure.
222 --
223 -- Prerequisites:
224 -- This private function can only be called from the upd process.
225 --
226 -- In Parameters:
227 -- A Pl/Sql record structre.
228 --
229 -- Post Success:
230 -- The record structure will be returned with all system defaulted parameter
231 -- values converted into its current row attribute value.
232 --
233 -- Post Failure:
234 -- No direct error handling is required within this function. Any possible
235 -- errors within this procedure will be a PL/SQL value error due to conversion
236
237 -- of datatypes or data lengths.
238 --
239 -- Developer Implementation Notes:
240 -- None.
241 --
242 -- Access Status:
243 -- Internal Row Handler Use Only.
244 --
245 -- {End Of Comments}
246 -- ----------------------------------------------------------------------------
247 Procedure convert_defs(p_rec in out nocopy hr_qsn_shd.g_rec_type) is
248 --
249 l_proc varchar2(72) := g_package||'convert_defs';
250 --
251 Begin
252 --
253 hr_utility.set_location('Entering:'||l_proc, 5);
254 --
255 -- We must now examine each argument value in the
256 -- p_rec plsql record structure
257 -- to see if a system default is being used. If a system default
258 -- is being used then we must set to the 'current' argument value.
259 --
260 If (p_rec.name = hr_api.g_varchar2) then
261 p_rec.name :=
262 hr_qsn_shd.g_old_rec.name;
263 End If;
264 If (p_rec.text = hr_api.g_varchar2) then
265 p_rec.text :=
266 hr_qsn_shd.g_old_rec.text;
267 End If;
268 If (p_rec.available_flag = hr_api.g_varchar2) then
269 p_rec.available_flag :=
270 hr_qsn_shd.g_old_rec.available_flag;
271 End If;
272 If (p_rec.business_group_id = hr_api.g_number) then
273 p_rec.business_group_id :=
274 hr_qsn_shd.g_old_rec.business_group_id;
275 End If;
276
277 --
278 hr_utility.set_location(' Leaving:'||l_proc, 10);
279 --
280 End convert_defs;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |---------------------------------< upd >----------------------------------|
284 -- ----------------------------------------------------------------------------
285 Procedure upd
286 (
287 p_rec in out nocopy hr_qsn_shd.g_rec_type,
288 p_effective_date in date
289 ) is
290 --
291 l_proc varchar2(72) := g_package||'upd';
292 --
293 Begin
294 hr_utility.set_location('Entering:'||l_proc, 5);
295 --
296 -- We must lock the row which we need to update.
297 --
298 hr_qsn_shd.lck
299 (
300 p_rec.questionnaire_template_id,
301 p_rec.object_version_number
302 );
303 --
304 -- 1. During an update system defaults are used to determine if
305 -- arguments have been defaulted or not. We must therefore
306 -- derive the full record structure values to be updated.
307 --
308 -- 2. Call the supporting update validate operations.
309 --
310 convert_defs(p_rec);
311 hr_qsn_bus.update_validate(p_rec, p_effective_date);
312 --
313 -- Call to raise any errors on multi-message list
314 hr_multi_message.end_validation_set;
315 --
316 --
317 -- Call the supporting pre-update operation
318 --
319 pre_update(p_rec);
320 --
321 -- Update the row.
322 --
323 update_dml(p_rec);
324 --
325 -- Call the supporting post-update operation
326 --
327 post_update(p_rec, p_effective_date);
328 -- Call to raise any errors on multi-message list
329 hr_multi_message.end_validation_set;
330 --
331 End upd;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |---------------------------------< upd >----------------------------------|
335 -- ----------------------------------------------------------------------------
336 Procedure upd
337 (
338 p_questionnaire_template_id in number,
339 p_text in CLOB,
340 p_available_flag in varchar2 default hr_api.g_varchar2,
341 p_business_group_id in number default hr_api.g_number,
342 p_object_version_number in out nocopy number,
343 p_effective_date in date
344 ) is
345 --
346 l_rec hr_qsn_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_qsn_shd.convert_args
357 (
358 p_questionnaire_template_id,
359 hr_api.g_varchar2,
360 p_text,
361 p_available_flag,
362 p_business_group_id,
363 p_object_version_number
364 );
365 --
366 -- Having converted the arguments into the
367 -- plsql record structure we call the corresponding record
368 -- business process.
369 --
370 upd(l_rec, p_effective_date);
371 p_object_version_number := l_rec.object_version_number;
372 --
373 hr_utility.set_location(' Leaving:'||l_proc, 10);
374 End upd;
375 --
376 end hr_qsn_upd;