DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_LCK_INS

Source


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