DBA Data[Home] [Help]

PACKAGE BODY: APPS.AME_RTL_INS

Source


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