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