DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_JBI_UPD

Source


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