1 Package Body hxc_atc_ins as
2 /* $Header: hxcatcrhi.pkb 120.2 2005/09/23 08:06:56 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_atc_ins.'; -- Global package name
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- The following global variables are only to be used by
12 -- the set_base_key_value and pre_insert procedures.
13 --
14 g_alias_type_component_id_i number default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20 (p_alias_type_component_id in number) is
21 --
22 l_proc varchar2(72);
23 --
24 Begin
25 g_debug:=hr_utility.debug_enabled;
26 if g_debug then
27 l_proc := g_package||'set_base_key_value';
28 hr_utility.set_location('Entering:'||l_proc, 10);
29 end if;
30 --
31 hxc_atc_ins.g_alias_type_component_id_i := p_alias_type_component_id;
32 --
33 if g_debug then
34 hr_utility.set_location(' Leaving:'||l_proc, 20);
35 end if;
36 End set_base_key_value;
37 --
38 --
39 -- ----------------------------------------------------------------------------
40 -- |------------------------------< insert_dml >------------------------------|
41 -- ----------------------------------------------------------------------------
42 -- {Start Of Comments}
43 --
44 -- Description:
45 -- This procedure controls the actual dml insert logic. The processing of
46 -- this procedure are as follows:
47 -- 1) Initialise the object_version_number to 1 if the object_version_number
48 -- is defined as an attribute for this entity.
49 -- 2) To set and unset the g_api_dml status as required (as we are about to
50 -- perform dml).
51 -- 3) To insert the row into the schema.
52 -- 4) To trap any constraint violations that may have occurred.
53 -- 5) To raise any other errors.
54 --
55 -- Prerequisites:
56 -- This is an internal private procedure which must be called from the ins
57 -- procedure and must have all mandatory attributes set (except the
58 -- object_version_number which is initialised within this procedure).
59 --
60 -- In Parameters:
61 -- A Pl/Sql record structre.
62 --
63 -- Post Success:
64 -- The specified row will be inserted into the schema.
65 --
66 -- Post Failure:
67 -- On the insert dml failure it is important to note that we always reset the
68 -- g_api_dml status to false.
69 -- If a check, unique or parent integrity constraint violation is raised the
70 -- constraint_error procedure will be called.
71 -- If any other error is reported, the error will be raised after the
72 -- g_api_dml status is reset.
73 --
74 -- Developer Implementation Notes:
75 -- None.
76 --
77 -- Access Status:
78 -- Internal Row Handler Use Only.
79 --
80 -- {End Of Comments}
81 -- ----------------------------------------------------------------------------
82 Procedure insert_dml
83 (p_rec in out nocopy hxc_atc_shd.g_rec_type
84 ) is
85 --
86 l_proc varchar2(72);
87 --
88 Begin
89 if g_debug then
90 l_proc := g_package||'insert_dml';
91 hr_utility.set_location('Entering:'||l_proc, 5);
92 end if;
93 p_rec.object_version_number := 1; -- Initialise the object version
94 --
95 --
96 --
97 -- Insert the row into: hxc_alias_type_components
98 --
99 insert into hxc_alias_type_components
100 (alias_type_component_id
101 ,component_name
102 ,component_type
103 ,mapping_component_id
104 ,alias_type_id
105 ,object_version_number
106 ,creation_date
107 ,created_by
108 ,last_updated_by
109 ,last_update_date
110 ,last_update_login
111
112 )
113 Values
114 (p_rec.alias_type_component_id
115 ,p_rec.component_name
116 ,p_rec.component_type
117 ,p_rec.mapping_component_id
118 ,p_rec.alias_type_id
119 ,p_rec.object_version_number
120 ,sysdate
121 ,fnd_global.user_id
122 ,fnd_global.user_id
123 ,sysdate
124 ,fnd_global.login_id
125 );
126 --
127 --
128 --
129 if g_debug then
130 hr_utility.set_location(' Leaving:'||l_proc, 10);
131 end if;
132 Exception
133 When hr_api.check_integrity_violated Then
134 -- A check constraint has been violated
135 --
136 hxc_atc_shd.constraint_error
137 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
138 When hr_api.parent_integrity_violated Then
139 -- Parent integrity has been violated
140 --
141 hxc_atc_shd.constraint_error
142 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
143 When hr_api.unique_integrity_violated Then
144 -- Unique integrity has been violated
145 --
146 hxc_atc_shd.constraint_error
147 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
148 When Others Then
149 --
150 Raise;
151 End insert_dml;
152 --
153 -- ----------------------------------------------------------------------------
154 -- |------------------------------< pre_insert >------------------------------|
155 -- ----------------------------------------------------------------------------
156 -- {Start Of Comments}
157 --
158 -- Description:
159 -- This private procedure contains any processing which is required before
160 -- the insert dml. Presently, if the entity has a corresponding primary
161 -- key which is maintained by an associating sequence, the primary key for
162 -- the entity will be populated with the next sequence value in
163 -- preparation for the insert dml.
164 --
165 -- Prerequisites:
166 -- This is an internal procedure which is called from the ins procedure.
167 --
168 -- In Parameters:
169 -- A Pl/Sql record structure.
170 --
171 -- Post Success:
172 -- Processing continues.
173 --
174 -- Post Failure:
175 -- If an error has occurred, an error message and exception will be raised
176 -- but not handled.
177 --
178 -- Developer Implementation Notes:
179 -- Any pre-processing required before the insert dml is issued should be
180 -- coded within this procedure. As stated above, a good example is the
181 -- generation of a primary key number via a corresponding sequence.
182 -- It is important to note that any 3rd party maintenance should be reviewed
183 -- before placing in this procedure.
184 --
185 -- Access Status:
186 -- Internal Row Handler Use Only.
187 --
188 -- {End Of Comments}
189 -- ----------------------------------------------------------------------------
190 Procedure pre_insert
191 (p_rec in out nocopy hxc_atc_shd.g_rec_type
192 ) is
193 --
194 Cursor C_Sel1 is select hxc_alias_type_components_s.nextval from sys.dual;
195 --
196 Cursor C_Sel2 is
197 Select null
198 from hxc_alias_type_components
199 where alias_type_component_id =
200 hxc_atc_ins.g_alias_type_component_id_i;
201 --
202 l_proc varchar2(72);
203 l_exists varchar2(1);
204 --
205 Begin
206 if g_debug then
207 l_proc := g_package||'pre_insert';
208 hr_utility.set_location('Entering:'||l_proc, 5);
209 end if;
210 --
211 If (hxc_atc_ins.g_alias_type_component_id_i is not null) Then
212 --
213 -- Verify registered primary key values not already in use
214 --
215 Open C_Sel2;
216 Fetch C_Sel2 into l_exists;
217 If C_Sel2%found Then
218 Close C_Sel2;
219 --
220 -- The primary key values are already in use.
221 --
222 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
223 fnd_message.set_token('TABLE_NAME','hxc_alias_type_components');
224 fnd_message.raise_error;
225 End If;
226 Close C_Sel2;
227 --
228 -- Use registered key values and clear globals
229 --
230 p_rec.alias_type_component_id :=
231 hxc_atc_ins.g_alias_type_component_id_i;
232 hxc_atc_ins.g_alias_type_component_id_i := null;
233 Else
234 --
235 -- No registerd key values, so select the next sequence number
236 --
237 --
238 -- Select the next sequence number
239 --
240 Open C_Sel1;
241 Fetch C_Sel1 Into p_rec.alias_type_component_id;
242 Close C_Sel1;
243 End If;
244 --
245 if g_debug then
246 hr_utility.set_location(' Leaving:'||l_proc, 10);
247 end if;
248 End pre_insert;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |-----------------------------< post_insert >------------------------------|
252 -- ----------------------------------------------------------------------------
253 -- {Start Of Comments}
254 --
255 -- Description:
256 -- This private procedure contains any processing which is required after
257 -- the insert dml.
258 --
259 -- Prerequisites:
260 -- This is an internal procedure which is called from the ins procedure.
261 --
262 -- In Parameters:
263 -- A Pl/Sql record structre.
264 --
265 -- Post Success:
266 -- Processing continues.
267 --
268 -- Post Failure:
269 -- If an error has occurred, an error message and exception will be raised
270 -- but not handled.
271 --
272 -- Developer Implementation Notes:
273 -- Any post-processing required after the insert dml is issued should be
274 -- coded within this procedure. It is important to note that any 3rd party
275 -- maintenance should be reviewed before placing in this procedure.
276 --
277 -- Access Status:
278 -- Internal Row Handler Use Only.
279 --
280 -- {End Of Comments}
281 -- ----------------------------------------------------------------------------
282 Procedure post_insert
283 (p_rec in hxc_atc_shd.g_rec_type
284 ) is
285 --
286 l_proc varchar2(72);
287 --
288 Begin
289 if g_debug then
290 l_proc := g_package||'post_insert';
291 hr_utility.set_location('Entering:'||l_proc, 5);
292 end if;
293 begin
294 --
295 hxc_atc_rki.after_insert
296 (p_alias_type_component_id
297 => p_rec.alias_type_component_id
298 ,p_component_name
299 => p_rec.component_name
300 ,p_component_type
301 => p_rec.component_type
302 ,p_mapping_component_id
303 => p_rec.mapping_component_id
304 ,p_alias_type_id
305 => p_rec.alias_type_id
306 ,p_object_version_number
307 => p_rec.object_version_number
308 );
309
310 hxc_time_category_utils_pkg.alias_type_comp_ref_int_chk ( p_rec.alias_type_id );
311
312 exception
313 --
314 when hr_api.cannot_find_prog_unit then
315 --
316 hr_api.cannot_find_prog_unit_error
317 (p_module_name => 'HXC_ALIAS_TYPE_COMPONENTS'
318 ,p_hook_type => 'AI');
319 --
320 end;
321 --
322 if g_debug then
323 hr_utility.set_location(' Leaving:'||l_proc, 10);
324 end if;
325 End post_insert;
326 --
327 -- ----------------------------------------------------------------------------
328 -- |---------------------------------< ins >----------------------------------|
329 -- ----------------------------------------------------------------------------
330 Procedure ins
331 (p_rec in out nocopy hxc_atc_shd.g_rec_type
332 ) is
333 --
334 l_proc varchar2(72);
335 --
336 Begin
337 g_debug:=hr_utility.debug_enabled;
338 if g_debug then
339 l_proc:= g_package||'ins';
340 hr_utility.set_location('Entering:'||l_proc, 5);
341 end if;
342 --
343 -- Call the supporting insert validate operations
344 --
345 hxc_atc_bus.insert_validate
346 (p_rec
347 );
348 --
349 -- Call to raise any errors on multi-message list
350 hr_multi_message.end_validation_set;
351 --
352 -- Call the supporting pre-insert operation
353 --
354 hxc_atc_ins.pre_insert(p_rec);
355 --
356 -- Insert the row
357 --
358 hxc_atc_ins.insert_dml(p_rec);
359 --
360 -- Call the supporting post-insert operation
361 --
362 hxc_atc_ins.post_insert
363 (p_rec
364 );
365 --
366 -- Call to raise any errors on multi-message list
367 hr_multi_message.end_validation_set;
368 --
369 if g_debug then
370 hr_utility.set_location('Leaving:'||l_proc, 20);
371 end if;
372 end ins;
373 --
374 -- ----------------------------------------------------------------------------
375 -- |---------------------------------< ins >----------------------------------|
376 -- ----------------------------------------------------------------------------
377 Procedure ins
378 (p_component_name in varchar2
379 ,p_component_type in varchar2
380 ,p_mapping_component_id in number
381 ,p_alias_type_id in number
382 ,p_alias_type_component_id out nocopy number
383 ,p_object_version_number out nocopy number
384 ) is
385 --
386 l_rec hxc_atc_shd.g_rec_type;
387 l_proc varchar2(72);
388 --
389 Begin
390 g_debug:=hr_utility.debug_enabled;
391 if g_debug then
392 l_proc := g_package||'ins';
393 hr_utility.set_location('Entering:'||l_proc, 5);
394 end if;
395 --
396 -- Call conversion function to turn arguments into the
397 -- p_rec structure.
398 --
399 l_rec :=
400 hxc_atc_shd.convert_args
401 (null
402 ,p_component_name
403 ,p_component_type
404 ,p_mapping_component_id
405 ,p_alias_type_id
406 ,null
407 );
408 --
409 -- Having converted the arguments into the hxc_atc_rec
410 -- plsql record structure we call the corresponding record business process.
411 --
412 hxc_atc_ins.ins
413 (l_rec
414 );
415 --
416 -- As the primary key argument(s)
417 -- are specified as an OUT's we must set these values.
418 --
419 p_alias_type_component_id := l_rec.alias_type_component_id;
420 p_object_version_number := l_rec.object_version_number;
421 --
422 if g_debug then
423 hr_utility.set_location(' Leaving:'||l_proc, 10);
424 end if;
425 End ins;
426 --
427 end hxc_atc_ins;