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