1 Package Body hxc_hat_ins as
2 /* $Header: hxchatrhi.pkb 120.2 2005/09/23 10:41:13 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_hat_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_id_i number default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20 (p_alias_type_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_hat_ins.g_alias_type_id_i := p_alias_type_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 >------------------------------|
44 -- Description:
41 -- ----------------------------------------------------------------------------
42 -- {Start Of Comments}
43 --
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_hat_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_types
98 --
99 insert into hxc_alias_types
100 (alias_type_id
101 ,alias_type
102 ,reference_object
103 ,object_version_number
104 ,creation_date
105 ,created_by
106 ,last_updated_by
107 ,last_update_date
108 ,last_update_login
109 )
110 Values
111 (p_rec.alias_type_id
112 ,p_rec.alias_type
113 ,p_rec.reference_object
114 ,p_rec.object_version_number
115 ,sysdate
116 ,fnd_global.user_id
117 ,fnd_global.user_id
118 ,sysdate
119 ,fnd_global.login_id
120 );
121 --
122 --
123 --
124 if g_debug then
125 hr_utility.set_location(' Leaving:'||l_proc, 10);
126 end if;
127 Exception
128 When hr_api.check_integrity_violated Then
129 -- A check constraint has been violated
130 --
131 hxc_hat_shd.constraint_error
132 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
133 When hr_api.parent_integrity_violated Then
134 -- Parent integrity has been violated
135 --
136 hxc_hat_shd.constraint_error
137 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
138 When hr_api.unique_integrity_violated Then
139 -- Unique integrity has been violated
140 --
141 hxc_hat_shd.constraint_error
142 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
143 When Others Then
144 --
145 Raise;
146 End insert_dml;
147 --
148 -- ----------------------------------------------------------------------------
149 -- |------------------------------< pre_insert >------------------------------|
150 -- ----------------------------------------------------------------------------
151 -- {Start Of Comments}
152 --
153 -- Description:
154 -- This private procedure contains any processing which is required before
155 -- the insert dml. Presently, if the entity has a corresponding primary
156 -- key which is maintained by an associating sequence, the primary key for
157 -- the entity will be populated with the next sequence value in
158 -- preparation for the insert dml.
159 --
160 -- Prerequisites:
161 -- This is an internal procedure which is called from the ins procedure.
162 --
163 -- In Parameters:
164 -- A Pl/Sql record structure.
165 --
166 -- Post Success:
167 -- Processing continues.
168 --
169 -- Post Failure:
170 -- If an error has occurred, an error message and exception will be raised
171 -- but not handled.
172 --
173 -- Developer Implementation Notes:
174 -- Any pre-processing required before the insert dml is issued should be
175 -- coded within this procedure. As stated above, a good example is the
176 -- generation of a primary key number via a corresponding sequence.
177 -- It is important to note that any 3rd party maintenance should be reviewed
178 -- before placing in this procedure.
179 --
180 -- Access Status:
181 -- Internal Row Handler Use Only.
182 --
183 -- {End Of Comments}
184 -- ----------------------------------------------------------------------------
185 Procedure pre_insert
186 (p_rec in out nocopy hxc_hat_shd.g_rec_type
187 ) is
188 --
189 Cursor C_Sel1 is select hxc_alias_types_s.nextval from sys.dual;
190 --
191 Cursor C_Sel2 is
192 Select null
193 from hxc_alias_types
197 l_proc varchar2(72);
194 where alias_type_id =
195 hxc_hat_ins.g_alias_type_id_i;
196 --
198 l_exists varchar2(1);
199 --
200 Begin
201 if g_debug then
202 l_proc:= g_package||'pre_insert';
203 hr_utility.set_location('Entering:'||l_proc, 5);
204 end if;
205 --
206 /* If (hxc_hat_ins.g_alias_type_id_i is not null) Then
207 --
208 -- Verify registered primary key values not already in use
209 --
210 Open C_Sel2;
211 Fetch C_Sel2 into l_exists;
212 If C_Sel2%found Then
213 Close C_Sel2;
214 --
215 -- The primary key values are already in use.
216 --
217 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
218 fnd_message.set_token('TABLE_NAME','hxc_alias_types');
219 fnd_message.raise_error;
220 End If;
221 Close C_Sel2;
222 --
223 -- Use registered key values and clear globals
224 --
225 p_rec.alias_type_id :=
226 hxc_hat_ins.g_alias_type_id_i;
227 hxc_hat_ins.g_alias_type_id_i := null;
228 Else
229 --
230 -- No registerd key values, so select the next sequence number
231 -- */
232 --
233 -- Select the next sequence number
234 --
235 Open C_Sel1;
236 Fetch C_Sel1 Into p_rec.alias_type_id;
237 Close C_Sel1;
238 -- End If;
239 --
240 if g_debug then
241 hr_utility.set_location(' Leaving:'||l_proc, 10);
242 end if;
243 End pre_insert;
244 --
245 -- ----------------------------------------------------------------------------
246 -- |-----------------------------< post_insert >------------------------------|
247 -- ----------------------------------------------------------------------------
248 -- {Start Of Comments}
249 --
250 -- Description:
251 -- This private procedure contains any processing which is required after
252 -- the insert dml.
253 --
254 -- Prerequisites:
255 -- This is an internal procedure which is called from the ins procedure.
256 --
257 -- In Parameters:
258 -- A Pl/Sql record structre.
259 --
260 -- Post Success:
261 -- Processing continues.
262 --
263 -- Post Failure:
264 -- If an error has occurred, an error message and exception will be raised
265 -- but not handled.
266 --
267 -- Developer Implementation Notes:
268 -- Any post-processing required after the insert dml is issued should be
269 -- coded within this procedure. It is important to note that any 3rd party
270 -- maintenance should be reviewed before placing in this procedure.
271 --
272 -- Access Status:
273 -- Internal Row Handler Use Only.
274 --
275 -- {End Of Comments}
276 -- ----------------------------------------------------------------------------
277 Procedure post_insert
278 (p_rec in hxc_hat_shd.g_rec_type
279 ) is
280 --
281 l_proc varchar2(72);
282 --
283 Begin
284 if g_debug then
285 l_proc := g_package||'post_insert';
286 hr_utility.set_location('Entering:'||l_proc, 5);
287 end if;
288 begin
289 --
290 hxc_hat_rki.after_insert
291 (p_alias_type_id
292 => p_rec.alias_type_id
293 ,p_alias_type
294 => p_rec.alias_type
295 ,p_reference_object
296 => p_rec.reference_object
297 ,p_object_version_number
298 => p_rec.object_version_number
299 );
300 --
301 exception
302 --
303 when hr_api.cannot_find_prog_unit then
304 --
305 hr_api.cannot_find_prog_unit_error
306 (p_module_name => 'HXC_ALIAS_TYPES'
307 ,p_hook_type => 'AI');
308 --
309 end;
310 --
311 if g_debug then
312 hr_utility.set_location(' Leaving:'||l_proc, 10);
313 end if;
314 End post_insert;
315 --
316 -- ----------------------------------------------------------------------------
317 -- |---------------------------------< ins >----------------------------------|
318 -- ----------------------------------------------------------------------------
319 Procedure ins
320 (p_rec in out nocopy hxc_hat_shd.g_rec_type
321 ) is
322 --
323 l_proc varchar2(72);
324 --
325 Begin
326 g_debug:=hr_utility.debug_enabled;
327 if g_debug then
328 l_proc := g_package||'ins';
329 hr_utility.set_location('Entering:'||l_proc, 5);
330 end if;
331 --
332 -- Call the supporting insert validate operations
333 --
334 hxc_hat_bus.insert_validate
335 (p_rec
336 );
337 --
338 -- Call to raise any errors on multi-message list
339 hr_multi_message.end_validation_set;
340 --
341 -- Call the supporting pre-insert operation
342 --
343 hxc_hat_ins.pre_insert(p_rec);
344 --
345 -- Insert the row
346 --
347 hxc_hat_ins.insert_dml(p_rec);
348 --
349 -- Call the supporting post-insert operation
350 --
351 hxc_hat_ins.post_insert
352 (p_rec
353 );
354 --
355 -- Call to raise any errors on multi-message list
356 hr_multi_message.end_validation_set;
357 --
358 if g_debug then
359 hr_utility.set_location('Leaving:'||l_proc, 20);
360 end if;
361 end ins;
362 --
363 -- ----------------------------------------------------------------------------
364 -- |---------------------------------< ins >----------------------------------|
368 ,p_reference_object in varchar2
365 -- ----------------------------------------------------------------------------
366 Procedure ins
367 (p_alias_type in varchar2
369 ,p_alias_type_id out nocopy number
370 ,p_object_version_number out nocopy number
371 ) is
372 --
373 l_rec hxc_hat_shd.g_rec_type;
374 l_proc varchar2(72);
375 --
376 Begin
377 g_debug:=hr_utility.debug_enabled;
378 if g_debug then
379 l_proc := g_package||'ins';
380 hr_utility.set_location('Entering:'||l_proc, 5);
381 end if;
382 --
383 -- Call conversion function to turn arguments into the
384 -- p_rec structure.
385 --
386 l_rec :=
387 hxc_hat_shd.convert_args
388 (null
389 ,p_alias_type
390 ,p_reference_object
391 ,null
392 );
393 --
394 -- Having converted the arguments into the hxc_hat_rec
395 -- plsql record structure we call the corresponding record business process.
396 --
397 hxc_hat_ins.ins
398 (l_rec
399 );
400 --
401 -- As the primary key argument(s)
402 -- are specified as an OUT's we must set these values.
403 --
404 p_alias_type_id := l_rec.alias_type_id;
405 p_object_version_number := l_rec.object_version_number;
406 --
407 if g_debug then
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 end if;
410 End ins;
411 --
412 end hxc_hat_ins;