DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_QSA_UPD

Source


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