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