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