DBA Data[Home] [Help]

PACKAGE BODY: APPS.FF_ARC_UPD

Source


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