DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_CAL_INS

Source


1 Package Body ame_cal_ins as
2 /* $Header: amcalrhi.pkb 120.2 2006/01/03 22:52 tkolla noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  ame_cal_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 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 insert the row into the schema.
23 --   4) To trap any constraint violations that may have occurred.
24 --   5) To raise any other errors.
25 --
26 -- Prerequisites:
27 --   This is an internal private procedure which must be called from the ins
28 --   procedure and must have all mandatory attributes set (except the
29 --   object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 --   A Pl/Sql record structre.
33 --
34 -- Post Success:
35 --   The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 --   On the insert 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 --   None.
47 --
48 -- Access Status:
49 --   Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml
54   (p_rec in out nocopy ame_cal_shd.g_rec_type
55   ) is
56 --
57   l_proc  varchar2(72) := g_package||'insert_dml';
58   l_current_user_id   number;
59   l_created_by        number;
60   l_last_updated_by   number;
61   l_last_update_login number;
62   l_creation_date     date;
63   l_last_update_date  date;
64 --
65 Begin
66   hr_utility.set_location('Entering:'||l_proc, 5);
67   --
68   --
69   --
70  l_current_user_id := fnd_global.user_id;
71  l_creation_date      := sysdate;
72  l_last_update_date   := sysdate;
73  if fnd_global.resp_name = 'AME Developer' then
74    l_created_by         := ame_util.seededDataCreatedById;
75  else
76    l_created_by         := l_current_user_id;
77  end if;
78  l_last_updated_by    := l_current_user_id;
79  l_last_update_login  := l_current_user_id;
80   --
81   -- Insert the row into: ame_calling_apps_tl
82   --
83   insert into ame_calling_apps_tl
84       (application_id
85       ,language
86       ,source_lang
87       ,application_name
88       ,created_by
89       ,creation_date
90       ,last_update_date
91       ,last_updated_by
92       ,last_update_login
93       )
94   Values
95     (p_rec.application_id
96     ,p_rec.language
97     ,p_rec.source_lang
98     ,p_rec.application_name
99     ,l_created_by
100     ,l_creation_date
101     ,l_last_update_date
102     ,l_last_updated_by
103     ,l_last_update_login
104     );
105   --
106   --
107   --
108   hr_utility.set_location(' Leaving:'||l_proc, 10);
109 Exception
110   When hr_api.check_integrity_violated Then
111     -- A check constraint has been violated
112     --
113     ame_cal_shd.constraint_error
114       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115   When hr_api.parent_integrity_violated Then
116     -- Parent integrity has been violated
117     --
118     ame_cal_shd.constraint_error
119       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120   When hr_api.unique_integrity_violated Then
121     -- Unique integrity has been violated
122     --
123     ame_cal_shd.constraint_error
124       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125   When Others Then
126     --
127     Raise;
128 End insert_dml;
129 --
130 -- ----------------------------------------------------------------------------
131 -- |------------------------------< pre_insert >------------------------------|
132 -- ----------------------------------------------------------------------------
133 -- {Start Of Comments}
134 --
135 -- Description:
136 --   This private procedure contains any processing which is required before
137 --   the insert dml. Presently, if the entity has a corresponding primary
138 --   key which is maintained by an associating sequence, the primary key for
139 --   the entity will be populated with the next sequence value in
140 --   preparation for the insert dml.
141 --
142 -- Prerequisites:
143 --   This is an internal procedure which is called from the ins procedure.
144 --
145 -- In Parameters:
146 --   A Pl/Sql record structre.
147 --
148 -- Post Success:
149 --   Processing continues.
150 --
151 -- Post Failure:
152 --   If an error has occurred, an error message and exception will be raised
153 --   but not handled.
154 --
155 -- Developer Implementation Notes:
156 --   Any pre-processing required before the insert dml is issued should be
157 --   coded within this procedure. As stated above, a good example is the
158 --   generation of a primary key number via a corresponding sequence.
159 --   It is important to note that any 3rd party maintenance should be reviewed
160 --   before placing in this procedure.
161 --
162 -- Access Status:
163 --   Internal Row Handler Use Only.
164 --
165 -- {End Of Comments}
166 -- ----------------------------------------------------------------------------
167 Procedure pre_insert
168   (p_rec                          in out nocopy ame_cal_shd.g_rec_type
169   ,p_application_id               in number
170   ) is
171 --
172   l_proc  varchar2(72) := g_package||'pre_insert';
173 --
174 Begin
175   hr_utility.set_location('Entering:'||l_proc, 5);
176   --
177   p_rec.application_id                   := p_application_id;
178   --
179   hr_utility.set_location(' Leaving:'||l_proc, 10);
180 End pre_insert;
181 --
182 -- ----------------------------------------------------------------------------
183 -- |-----------------------------< post_insert >------------------------------|
184 -- ----------------------------------------------------------------------------
185 -- {Start Of Comments}
186 --
187 -- Description:
188 --   This private procedure contains any processing which is required after
189 --   the insert dml.
190 --
191 -- Prerequisites:
192 --   This is an internal procedure which is called from the ins procedure.
193 --
194 -- In Parameters:
195 --   A Pl/Sql record structre.
196 --
197 -- Post Success:
198 --   Processing continues.
199 --
200 -- Post Failure:
201 --   If an error has occurred, an error message and exception will be raised
202 --   but not handled.
203 --
204 -- Developer Implementation Notes:
205 --   Any post-processing required after the insert dml is issued should be
206 --   coded within this procedure. It is important to note that any 3rd party
207 --   maintenance should be reviewed before placing in this procedure.
208 --
209 -- Access Status:
210 --   Internal Row Handler Use Only.
211 --
212 -- {End Of Comments}
213 -- ----------------------------------------------------------------------------
214 Procedure post_insert
215   (p_rec                          in ame_cal_shd.g_rec_type
216   ) is
217 --
218   l_proc  varchar2(72) := g_package||'post_insert';
219 --
220 Begin
221   hr_utility.set_location('Entering:'||l_proc, 5);
222   begin
223     --
224     ame_cal_rki.after_insert
225       (p_application_id
226       => p_rec.application_id
227       ,p_language
228       => p_rec.language
229       ,p_source_lang
230       => p_rec.source_lang
231       ,p_application_name
232       => p_rec.application_name
233       );
234     --
235   exception
236     --
237     when hr_api.cannot_find_prog_unit then
238       --
239       hr_api.cannot_find_prog_unit_error
240         (p_module_name => 'AME_CALLING_APPS_TL'
241         ,p_hook_type   => 'AI');
242       --
243   end;
244   --
245   hr_utility.set_location(' Leaving:'||l_proc, 10);
246 End post_insert;
247 --
248 -- ----------------------------------------------------------------------------
249 -- |---------------------------------< ins >----------------------------------|
250 -- ----------------------------------------------------------------------------
251 Procedure ins
252   (p_rec                          in out nocopy ame_cal_shd.g_rec_type
253   ,p_application_id               in number
254   ) is
255 --
256   l_proc  varchar2(72) := g_package||'ins';
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   --
261   -- Call the supporting insert validate operations
262   --
263   ame_cal_bus.insert_validate
264      (p_rec
265      );
266   --
267   -- Call to raise any errors on multi-message list
268   hr_multi_message.end_validation_set;
269   --
270   -- Call the supporting pre-insert operation
271   --
272   ame_cal_ins.pre_insert
273     (p_rec                         => p_rec
274     ,p_application_id              => p_application_id
275     );
276   --
277   -- Insert the row
278   --
279   ame_cal_ins.insert_dml(p_rec);
280   --
281   -- Call the supporting post-insert operation
282   --
283   ame_cal_ins.post_insert
284      (p_rec
285      );
286   --
287   -- Call to raise any errors on multi-message list
288   hr_multi_message.end_validation_set;
289   --
290   hr_utility.set_location('Leaving:'||l_proc, 20);
291 end ins;
292 --
293 -- ----------------------------------------------------------------------------
294 -- |---------------------------------< ins >----------------------------------|
295 -- ----------------------------------------------------------------------------
296 Procedure ins
297   (p_application_id                 in     number
298   ,p_language                       in     varchar2
299   ,p_source_lang                    in     varchar2
300   ,p_application_name               in     varchar2
301   ) is
302 --
303   l_rec   ame_cal_shd.g_rec_type;
304   l_proc  varchar2(72) := g_package||'ins';
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   --
309   -- Call conversion function to turn arguments into the
310   -- p_rec structure.
311   --
312   l_rec :=
313   ame_cal_shd.convert_args
314     (p_application_id
315     ,p_language
316     ,p_source_lang
317     ,p_application_name
318     );
319   --
320   -- Having converted the arguments into the ame_cal_rec
321   -- plsql record structure we call the corresponding record business process.
322   --
323   ame_cal_ins.ins
324      (p_rec                         => l_rec
325      ,p_application_id              => p_application_id
326      );
327   --
328   -- As the primary key argument(s)
329   -- are specified as an OUT's we must set these values.
330   --
331   --
332   --
333   hr_utility.set_location(' Leaving:'||l_proc, 10);
334 End ins;
335 --
336 -- ----------------------------------------------------------------------------
337 -- |------------------------------< ins_tl >----------------------------------|
338 -- ----------------------------------------------------------------------------
339 Procedure ins_tl
340   (p_language_code               in varchar2
341   ,p_application_id               in number
342   ,p_application_name             in varchar2
343   ) is
344   --
345   -- Cursor to obtain the list of base and installed languages
346   --
347   cursor csr_ins_langs is
348     select l.language_code
349       from fnd_languages l
350      where l.installed_flag in ('I','B')
351        and not exists (select null
352                          from ame_calling_apps_tl cal
353                         where cal.application_id = p_application_id
354                           and cal.language = l.language_code);
355   --
356   l_proc  varchar2(72)  := g_package || 'ins_tl';
357   --
358 Begin
359   hr_utility.set_location('Entering:'||l_proc,10);
360   --
361   -- Insert a row for the base language and every installed language.
362   --
363   for l_lang in csr_ins_langs loop
364     ame_cal_ins.ins
365       (p_application_id              => p_application_id
366       ,p_language                    => l_lang.language_code
367       ,p_source_lang                 => p_language_code
368       ,p_application_name            => p_application_name
369       );
370   end loop;
371   --
372   hr_utility.set_location('Leaving:'||l_proc,20);
373 End ins_tl;
374 --
375 end ame_cal_ins;