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