DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_ADI_LOB_UPD

Source


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