DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_INO_UPD

Source


1 Package Body irc_ino_upd as
2 /* $Header: irinorhi.pkb 120.1 2005/10/04 06:25:18 kthavran noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_ino_upd.';  -- Global package name
9 g_note_text boolean;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< update_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 --   This procedure controls the actual dml update logic. The processing of
18 --   this procedure is:
19 --   1) Increment the object_version_number by 1 if the object_version_number
20 --      is defined as an attribute for this entity.
21 --   2) To set and unset the g_api_dml status as required (as we are about to
22 --      perform dml).
23 --   3) To update the specified row in the schema using the primary key in
24 --      the predicates.
25 --   4) To trap any constraint violations that may have occurred.
26 --   5) To raise any other errors.
27 --
28 -- Prerequisites:
29 --   This is an internal private procedure which must be called from the upd
30 --   procedure.
31 --
32 -- In Parameters:
33 --   A Pl/Sql record structre.
34 --
35 -- Post Success:
36 --   The specified row will be updated in the schema.
37 --
38 -- Post Failure:
39 --   On the update dml failure it is important to note that we always reset the
40 --   g_api_dml status to false.
41 --   If a check, unique or parent integrity constraint violation is raised the
42 --   constraint_error procedure will be called.
43 --   If any other error is reported, the error will be raised after the
44 --   g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 --   The update 'set' attribute list should be modified if any of your
48 --   attributes are not updateable.
49 --
50 -- Access Status:
51 --   Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure update_dml
56   (p_rec in out nocopy irc_ino_shd.g_rec_type
57   ) is
58 --
59   l_proc  varchar2(72) := g_package||'update_dml';
60   l_note_text clob;
61 --
62 Begin
63   hr_utility.set_location('Entering:'||l_proc, 5);
64   --
65   -- Increment the object version
66   p_rec.object_version_number := p_rec.object_version_number + 1;
67   --
68   irc_ino_shd.g_api_dml := true;  -- Set the api dml status
69   --
70   -- Update the irc_notes Row
71   --
72   update irc_notes
73     set
74      note_id                         = p_rec.note_id
75     ,offer_status_history_id         = p_rec.offer_status_history_id
76     ,object_version_number           = p_rec.object_version_number
77     where note_id = p_rec.note_id
78     returning note_text into l_note_text;
79   --
80     if (g_note_text
81        and dbms_lob.getlength(l_note_text)<=32767
82        and dbms_lob.instr(l_note_text,p_rec.note_text)<>1)
83     then
84       hr_utility.set_location(l_proc, 10);
85       dbms_lob.trim(l_note_text,0);
86       dbms_lob.write(l_note_text
87                     ,length(p_rec.note_text)
88                     ,1
89                     ,p_rec.note_text);
90     end if;
91   irc_ino_shd.g_api_dml := false;   -- Unset the api dml status
92   --
93   hr_utility.set_location(' Leaving:'||l_proc, 10);
94 --
95 Exception
96   When hr_api.check_integrity_violated Then
97     -- A check constraint has been violated
98     irc_ino_shd.g_api_dml := false;   -- Unset the api dml status
99     irc_ino_shd.constraint_error
100       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
101   When hr_api.parent_integrity_violated Then
102     -- Parent integrity has been violated
103     irc_ino_shd.g_api_dml := false;   -- Unset the api dml status
104     irc_ino_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When hr_api.unique_integrity_violated Then
107     -- Unique integrity has been violated
108     irc_ino_shd.g_api_dml := false;   -- Unset the api dml status
109     irc_ino_shd.constraint_error
110       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
111   When Others Then
112     irc_ino_shd.g_api_dml := false;   -- Unset the api dml status
113     Raise;
114 End update_dml;
115 --
116 -- ----------------------------------------------------------------------------
117 -- |------------------------------< pre_update >------------------------------|
118 -- ----------------------------------------------------------------------------
119 -- {Start Of Comments}
120 --
121 -- Description:
122 --   This private procedure contains any processing which is required before
123 --   the update dml.
124 --
125 -- Prerequisites:
126 --   This is an internal procedure which is called from the upd procedure.
127 --
128 -- In Parameters:
129 --   A Pl/Sql record structure.
130 --
131 -- Post Success:
132 --   Processing continues.
133 --
134 -- Post Failure:
135 --   If an error has occurred, an error message and exception wil be raised
136 --   but not handled.
137 --
138 -- Developer Implementation Notes:
139 --   Any pre-processing required before the update dml is issued should be
140 --   coded within this procedure. It is important to note that any 3rd party
141 --   maintenance should be reviewed before placing in this procedure.
142 --
143 -- Access Status:
144 --   Internal Row Handler Use Only.
145 --
146 -- {End Of Comments}
147 -- ----------------------------------------------------------------------------
148 Procedure pre_update
149   (p_rec in irc_ino_shd.g_rec_type
150   ) is
151 --
152   l_proc  varchar2(72) := g_package||'pre_update';
153 --
154 Begin
155   hr_utility.set_location('Entering:'||l_proc, 5);
156   --
157   hr_utility.set_location(' Leaving:'||l_proc, 10);
158 End pre_update;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |-----------------------------< post_update >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This private procedure contains any processing which is required after
167 --   the update dml.
168 --
169 -- Prerequisites:
170 --   This is an internal procedure which is called from the upd procedure.
171 --
172 -- In Parameters:
173 --   A Pl/Sql record structure.
174 --
175 -- Post Success:
176 --   Processing continues.
177 --
178 -- Post Failure:
179 --   If an error has occurred, an error message and exception will be raised
180 --   but not handled.
181 --
182 -- Developer Implementation Notes:
183 --   Any post-processing required after the update dml is issued should be
184 --   coded within this procedure. It is important to note that any 3rd party
185 --   maintenance should be reviewed before placing in this procedure.
186 --
187 -- Access Status:
188 --   Internal Row Handler Use Only.
189 --
190 -- {End Of Comments}
191 -- ----------------------------------------------------------------------------
192 Procedure post_update
193   (p_rec                          in irc_ino_shd.g_rec_type
194   ) is
195 --
196   l_proc  varchar2(72) := g_package||'post_update';
197 --
198 Begin
199   hr_utility.set_location('Entering:'||l_proc, 5);
200   begin
201     --
202     irc_ino_rku.after_update
203       (p_note_id
204       => p_rec.note_id
205       ,p_offer_status_history_id
206       => p_rec.offer_status_history_id
207       ,p_note_text
208       => p_rec.note_text
209       ,p_object_version_number
210       => p_rec.object_version_number
211       ,p_offer_status_history_id_o
212       => irc_ino_shd.g_old_rec.offer_status_history_id
213       ,p_note_text_o
214       => irc_ino_shd.g_old_rec.note_text
215       ,p_object_version_number_o
216       => irc_ino_shd.g_old_rec.object_version_number
217       );
218     --
219   exception
220     --
221     when hr_api.cannot_find_prog_unit then
222       --
223       hr_api.cannot_find_prog_unit_error
224         (p_module_name => 'IRC_NOTES'
225         ,p_hook_type   => 'AU');
226       --
227   end;
228   --
229   hr_utility.set_location(' Leaving:'||l_proc, 10);
230 End post_update;
231 --
232 -- ----------------------------------------------------------------------------
233 -- |-----------------------------< convert_defs >-----------------------------|
234 -- ----------------------------------------------------------------------------
235 -- {Start Of Comments}
236 --
237 -- Description:
238 --   The Convert_Defs procedure has one very important function:
239 --   It must return the record structure for the row with all system defaulted
240 --   values converted into its corresponding parameter value for update. When
241 --   we attempt to update a row through the Upd process , certain
242 --   parameters can be defaulted which enables flexibility in the calling of
243 --   the upd process (e.g. only attributes which need to be updated need to be
244 --   specified). For the upd process to determine which attributes
245 --   have NOT been specified we need to check if the parameter has a reserved
246 --   system default value. Therefore, for all parameters which have a
247 --   corresponding reserved system default mechanism specified we need to
248 --   check if a system default is being used. If a system default is being
249 --   used then we convert the defaulted value into its corresponding attribute
250 --   value held in the g_old_rec data structure.
251 --
252 -- Prerequisites:
253 --   This private function can only be called from the upd process.
254 --
255 -- In Parameters:
256 --   A Pl/Sql record structure.
257 --
258 -- Post Success:
259 --   The record structure will be returned with all system defaulted parameter
260 --   values converted into its current row attribute value.
261 --
262 -- Post Failure:
263 --   No direct error handling is required within this function. Any possible
264 --   errors within this procedure will be a PL/SQL value error due to
265 --   conversion of datatypes or data lengths.
266 --
267 -- Developer Implementation Notes:
268 --   None.
269 --
270 -- Access Status:
271 --   Internal Row Handler Use Only.
272 --
273 -- {End Of Comments}
274 -- ----------------------------------------------------------------------------
275 Procedure convert_defs
276   (p_rec in out nocopy irc_ino_shd.g_rec_type
277   ) is
278 --
279 Begin
280   --
281   -- We must now examine each argument value in the
282   -- p_rec plsql record structure
283   -- to see if a system default is being used. If a system default
284   -- is being used then we must set to the 'current' argument value.
285   --
286   If (p_rec.offer_status_history_id = hr_api.g_number) then
287     p_rec.offer_status_history_id :=
288     irc_ino_shd.g_old_rec.offer_status_history_id;
289   End If;
290   If (p_rec.note_text = hr_api.g_varchar2) then
291     p_rec.note_text :=
292     irc_ino_shd.g_old_rec.note_text;
293     g_note_text:=false;
294   Else
295     g_note_text:=true;
296   End If;
297   --
298 End convert_defs;
299 --
300 -- ----------------------------------------------------------------------------
301 -- |---------------------------------< upd >----------------------------------|
302 -- ----------------------------------------------------------------------------
303 Procedure upd
304   (p_rec                          in out nocopy irc_ino_shd.g_rec_type
305   ) is
306 --
307   l_proc  varchar2(72) := g_package||'upd';
308 --
309 Begin
310   hr_utility.set_location('Entering:'||l_proc, 5);
311   --
312   -- We must lock the row which we need to update.
313   --
314   irc_ino_shd.lck
315     (p_rec.note_id
316     ,p_rec.object_version_number
317     );
318   --
319   -- 1. During an update system defaults are used to determine if
320   --    arguments have been defaulted or not. We must therefore
321   --    derive the full record structure values to be updated.
322   --
323   -- 2. Call the supporting update validate operations.
324   --
325   convert_defs(p_rec);
326   irc_ino_bus.update_validate
327      (p_rec
328      );
329   --
330   -- Call to raise any errors on multi-message list
331   hr_multi_message.end_validation_set;
332   --
333   -- Call the supporting pre-update operation
334   --
335   irc_ino_upd.pre_update(p_rec);
336   --
337   -- Update the row.
338   --
339   irc_ino_upd.update_dml(p_rec);
340   --
341   -- Call the supporting post-update operation
342   --
343   irc_ino_upd.post_update
344      (p_rec
345      );
346   --
347   -- Call to raise any errors on multi-message list
348   hr_multi_message.end_validation_set;
349 End upd;
350 --
351 -- ----------------------------------------------------------------------------
352 -- |---------------------------------< upd >----------------------------------|
353 -- ----------------------------------------------------------------------------
354 Procedure upd
355   (p_note_id                      in     number
356   ,p_object_version_number        in out nocopy number
357   ,p_offer_status_history_id      in     number    default hr_api.g_number
358   ,p_note_text                    in     varchar2  default hr_api.g_varchar2
359   ) is
360 --
361   l_rec   irc_ino_shd.g_rec_type;
362   l_proc  varchar2(72) := g_package||'upd';
363 --
364 Begin
365   hr_utility.set_location('Entering:'||l_proc, 5);
366   --
367   -- Call conversion function to turn arguments into the
368   -- l_rec structure.
369   --
370   l_rec :=
371   irc_ino_shd.convert_args
372   (p_note_id
373   ,p_offer_status_history_id
374   ,p_note_text
375   ,p_object_version_number
376   );
377   --
378   -- Having converted the arguments into the
379   -- plsql record structure we call the corresponding record
380   -- business process.
381   --
382   irc_ino_upd.upd
383      (l_rec
384      );
385   p_object_version_number := l_rec.object_version_number;
386   --
387   hr_utility.set_location(' Leaving:'||l_proc, 10);
388 End upd;
389 --
390 end irc_ino_upd;