DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_RTM_UPD

Source


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