DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_MCU_INS

Source


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