DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TAH_UPD

Source


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