DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_ANC_INS

Source


1 Package Body ota_anc_ins as
2 /* $Header: otancrhi.pkb 115.0 2003/12/01 05:59 arkashya noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ota_anc_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_announcement_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_announcement_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   ota_anc_ins.g_announcement_id_i := p_announcement_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy ota_anc_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: ota_announcements
88   --
89   insert into ota_announcements
90       (announcement_id
91       ,business_group_id
92       ,object_version_number
93       ,start_date_active
94       ,end_date_active
95       ,owner_id
96       ,attribute_category
97       ,attribute1
98       ,attribute2
99       ,attribute3
100       ,attribute4
101       ,attribute5
102       ,attribute6
103       ,attribute7
104       ,attribute8
105       ,attribute9
106       ,attribute10
107       ,attribute11
108       ,attribute12
109       ,attribute13
110       ,attribute14
111       ,attribute15
112       ,attribute16
113       ,attribute17
114       ,attribute18
115       ,attribute19
116       ,attribute20
117       )
118   Values
119     (p_rec.announcement_id
120     ,p_rec.business_group_id
121     ,p_rec.object_version_number
122     ,p_rec.start_date_active
123     ,p_rec.end_date_active
124     ,p_rec.owner_id
125     ,p_rec.attribute_category
126     ,p_rec.attribute1
127     ,p_rec.attribute2
128     ,p_rec.attribute3
129     ,p_rec.attribute4
130     ,p_rec.attribute5
131     ,p_rec.attribute6
132     ,p_rec.attribute7
133     ,p_rec.attribute8
134     ,p_rec.attribute9
135     ,p_rec.attribute10
136     ,p_rec.attribute11
137     ,p_rec.attribute12
138     ,p_rec.attribute13
139     ,p_rec.attribute14
140     ,p_rec.attribute15
141     ,p_rec.attribute16
142     ,p_rec.attribute17
143     ,p_rec.attribute18
144     ,p_rec.attribute19
145     ,p_rec.attribute20
146     );
147   --
148   --
149   --
150   hr_utility.set_location(' Leaving:'||l_proc, 10);
151 Exception
152   When hr_api.check_integrity_violated Then
153     -- A check constraint has been violated
154     --
155     ota_anc_shd.constraint_error
156       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
157   When hr_api.parent_integrity_violated Then
158     -- Parent integrity has been violated
159     --
160     ota_anc_shd.constraint_error
161       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
162   When hr_api.unique_integrity_violated Then
163     -- Unique integrity has been violated
164     --
165     ota_anc_shd.constraint_error
166       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
167   When Others Then
168     --
169     Raise;
170 End insert_dml;
171 --
172 -- ----------------------------------------------------------------------------
173 -- |------------------------------< pre_insert >------------------------------|
174 -- ----------------------------------------------------------------------------
175 -- {Start Of Comments}
176 --
177 -- Description:
178 --   This private procedure contains any processing which is required before
179 --   the insert dml. Presently, if the entity has a corresponding primary
180 --   key which is maintained by an associating sequence, the primary key for
181 --   the entity will be populated with the next sequence value in
182 --   preparation for the insert dml.
183 --
184 -- Prerequisites:
185 --   This is an internal procedure which is called from the ins procedure.
186 --
187 -- In Parameters:
188 --   A Pl/Sql record structure.
189 --
190 -- Post Success:
191 --   Processing continues.
192 --
193 -- Post Failure:
194 --   If an error has occurred, an error message and exception will be raised
195 --   but not handled.
196 --
197 -- Developer Implementation Notes:
198 --   Any pre-processing required before the insert dml is issued should be
199 --   coded within this procedure. As stated above, a good example is the
200 --   generation of a primary key number via a corresponding sequence.
201 --   It is important to note that any 3rd party maintenance should be reviewed
202 --   before placing in this procedure.
203 --
204 -- Access Status:
205 --   Internal Row Handler Use Only.
206 --
207 -- {End Of Comments}
208 -- ----------------------------------------------------------------------------
209 Procedure pre_insert
210   (p_rec  in out nocopy ota_anc_shd.g_rec_type
211   ) is
212 --
213   Cursor C_Sel1 is select ota_announcements_s.nextval from sys.dual;
214 --
215   Cursor C_Sel2 is
216     Select null
217       from ota_announcements
218      where announcement_id =
219              ota_anc_ins.g_announcement_id_i;
220 --
221   l_proc   varchar2(72) := g_package||'pre_insert';
222   l_exists varchar2(1);
223 --
224 Begin
225   hr_utility.set_location('Entering:'||l_proc, 5);
226   --
227   If (ota_anc_ins.g_announcement_id_i is not null) Then
228     --
229     -- Verify registered primary key values not already in use
230     --
231     Open C_Sel2;
232     Fetch C_Sel2 into l_exists;
233     If C_Sel2%found Then
234        Close C_Sel2;
235        --
236        -- The primary key values are already in use.
237        --
238        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
239        fnd_message.set_token('TABLE_NAME','ota_announcements');
240        fnd_message.raise_error;
241     End If;
242     Close C_Sel2;
243     --
244     -- Use registered key values and clear globals
245     --
246     p_rec.announcement_id :=
247       ota_anc_ins.g_announcement_id_i;
248     ota_anc_ins.g_announcement_id_i := null;
249   Else
250     --
251     -- No registerd key values, so select the next sequence number
252     --
253     --
254     -- Select the next sequence number
255     --
256     Open C_Sel1;
257     Fetch C_Sel1 Into p_rec.announcement_id;
258     Close C_Sel1;
259   End If;
260   --
261   hr_utility.set_location(' Leaving:'||l_proc, 10);
262 End pre_insert;
263 --
264 -- ----------------------------------------------------------------------------
265 -- |-----------------------------< post_insert >------------------------------|
266 -- ----------------------------------------------------------------------------
267 -- {Start Of Comments}
268 --
269 -- Description:
270 --   This private procedure contains any processing which is required after
271 --   the insert dml.
272 --
273 -- Prerequisites:
274 --   This is an internal procedure which is called from the ins procedure.
275 --
276 -- In Parameters:
277 --   A Pl/Sql record structre.
278 --
279 -- Post Success:
280 --   Processing continues.
281 --
282 -- Post Failure:
283 --   If an error has occurred, an error message and exception will be raised
284 --   but not handled.
285 --
286 -- Developer Implementation Notes:
287 --   Any post-processing required after the insert dml is issued should be
288 --   coded within this procedure. It is important to note that any 3rd party
289 --   maintenance should be reviewed before placing in this procedure.
290 --
291 -- Access Status:
292 --   Internal Row Handler Use Only.
293 --
294 -- {End Of Comments}
295 -- ----------------------------------------------------------------------------
296 Procedure post_insert
297   (p_effective_date               in date
298   ,p_rec                          in ota_anc_shd.g_rec_type
299   ) is
300 --
301   l_proc  varchar2(72) := g_package||'post_insert';
302 --
303 Begin
304   hr_utility.set_location('Entering:'||l_proc, 5);
305   begin
306     --
307     ota_anc_rki.after_insert
308       (p_effective_date              => p_effective_date
309       ,p_announcement_id
310       => p_rec.announcement_id
311       ,p_business_group_id
312       => p_rec.business_group_id
313       ,p_object_version_number
314       => p_rec.object_version_number
315       ,p_start_date_active
316       => p_rec.start_date_active
317       ,p_end_date_active
318       => p_rec.end_date_active
319       ,p_owner_id
320       => p_rec.owner_id
321       ,p_attribute_category
322       => p_rec.attribute_category
323       ,p_attribute1
324       => p_rec.attribute1
325       ,p_attribute2
326       => p_rec.attribute2
327       ,p_attribute3
328       => p_rec.attribute3
329       ,p_attribute4
330       => p_rec.attribute4
331       ,p_attribute5
332       => p_rec.attribute5
333       ,p_attribute6
334       => p_rec.attribute6
335       ,p_attribute7
336       => p_rec.attribute7
337       ,p_attribute8
338       => p_rec.attribute8
339       ,p_attribute9
340       => p_rec.attribute9
341       ,p_attribute10
342       => p_rec.attribute10
343       ,p_attribute11
344       => p_rec.attribute11
345       ,p_attribute12
346       => p_rec.attribute12
347       ,p_attribute13
348       => p_rec.attribute13
349       ,p_attribute14
350       => p_rec.attribute14
351       ,p_attribute15
352       => p_rec.attribute15
353       ,p_attribute16
354       => p_rec.attribute16
355       ,p_attribute17
356       => p_rec.attribute17
357       ,p_attribute18
358       => p_rec.attribute18
359       ,p_attribute19
360       => p_rec.attribute19
361       ,p_attribute20
362       => p_rec.attribute20
363       );
364     --
365   exception
366     --
367     when hr_api.cannot_find_prog_unit then
368       --
369       hr_api.cannot_find_prog_unit_error
370         (p_module_name => 'OTA_ANNOUNCEMENTS'
371         ,p_hook_type   => 'AI');
372       --
373   end;
374   --
375   hr_utility.set_location(' Leaving:'||l_proc, 10);
376 End post_insert;
377 --
378 -- ----------------------------------------------------------------------------
379 -- |---------------------------------< ins >----------------------------------|
380 -- ----------------------------------------------------------------------------
381 Procedure ins
382   (p_effective_date               in date
383   ,p_rec                          in out nocopy ota_anc_shd.g_rec_type
384   ) is
385 --
386   l_proc  varchar2(72) := g_package||'ins';
387 --
388 Begin
389   hr_utility.set_location('Entering:'||l_proc, 5);
390   --
391   -- Call the supporting insert validate operations
392   --
393   ota_anc_bus.insert_validate
394      (p_effective_date
395      ,p_rec
396      );
397   --
398   -- Call to raise any errors on multi-message list
399   hr_multi_message.end_validation_set;
400   --
401   -- Call the supporting pre-insert operation
402   --
403   ota_anc_ins.pre_insert(p_rec);
404   --
405   -- Insert the row
406   --
407   ota_anc_ins.insert_dml(p_rec);
408   --
409   -- Call the supporting post-insert operation
410   --
411   ota_anc_ins.post_insert
412      (p_effective_date
413      ,p_rec
414      );
415   --
416   -- Call to raise any errors on multi-message list
417   hr_multi_message.end_validation_set;
418   --
419   hr_utility.set_location('Leaving:'||l_proc, 20);
420 end ins;
421 --
422 -- ----------------------------------------------------------------------------
423 -- |---------------------------------< ins >----------------------------------|
424 -- ----------------------------------------------------------------------------
425 Procedure ins
426   (p_effective_date               in     date
427   ,p_business_group_id              in     number
428   ,p_start_date_active              in     date     default null
429   ,p_end_date_active                in     date     default null
430   ,p_owner_id                       in     number   default null
431   ,p_attribute_category             in     varchar2 default null
432   ,p_attribute1                     in     varchar2 default null
433   ,p_attribute2                     in     varchar2 default null
434   ,p_attribute3                     in     varchar2 default null
435   ,p_attribute4                     in     varchar2 default null
436   ,p_attribute5                     in     varchar2 default null
437   ,p_attribute6                     in     varchar2 default null
438   ,p_attribute7                     in     varchar2 default null
439   ,p_attribute8                     in     varchar2 default null
440   ,p_attribute9                     in     varchar2 default null
441   ,p_attribute10                    in     varchar2 default null
442   ,p_attribute11                    in     varchar2 default null
443   ,p_attribute12                    in     varchar2 default null
444   ,p_attribute13                    in     varchar2 default null
445   ,p_attribute14                    in     varchar2 default null
446   ,p_attribute15                    in     varchar2 default null
447   ,p_attribute16                    in     varchar2 default null
448   ,p_attribute17                    in     varchar2 default null
449   ,p_attribute18                    in     varchar2 default null
450   ,p_attribute19                    in     varchar2 default null
451   ,p_attribute20                    in     varchar2 default null
452   ,p_announcement_id                   out nocopy number
453   ,p_object_version_number             out nocopy number
454   ) is
455 --
456   l_rec   ota_anc_shd.g_rec_type;
457   l_proc  varchar2(72) := g_package||'ins';
458 --
459 Begin
460   hr_utility.set_location('Entering:'||l_proc, 5);
461   --
462   -- Call conversion function to turn arguments into the
463   -- p_rec structure.
464   --
465   l_rec :=
466   ota_anc_shd.convert_args
467     (null
468     ,p_business_group_id
469     ,null
470     ,p_start_date_active
471     ,p_end_date_active
472     ,p_owner_id
473     ,p_attribute_category
474     ,p_attribute1
475     ,p_attribute2
476     ,p_attribute3
477     ,p_attribute4
478     ,p_attribute5
479     ,p_attribute6
480     ,p_attribute7
481     ,p_attribute8
482     ,p_attribute9
483     ,p_attribute10
484     ,p_attribute11
485     ,p_attribute12
486     ,p_attribute13
487     ,p_attribute14
488     ,p_attribute15
489     ,p_attribute16
490     ,p_attribute17
491     ,p_attribute18
492     ,p_attribute19
493     ,p_attribute20
494     );
495   --
496   -- Having converted the arguments into the ota_anc_rec
497   -- plsql record structure we call the corresponding record business process.
498   --
499   ota_anc_ins.ins
500      (p_effective_date
501      ,l_rec
502      );
503   --
504   -- As the primary key argument(s)
505   -- are specified as an OUT's we must set these values.
506   --
507   p_announcement_id := l_rec.announcement_id;
508   p_object_version_number := l_rec.object_version_number;
509   --
510   hr_utility.set_location(' Leaving:'||l_proc, 10);
511 End ins;
512 --
513 end ota_anc_ins;