DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HSD_INS

Source


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