DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_ATL_INS

Source


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