1 Package Body hxc_mpc_ins as
2 /* $Header: hxcmpcrhi.pkb 120.2 2005/09/23 08:47:45 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_mpc_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_mpc_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_mpc_shd.g_api_dml := true; -- Set the api dml status
71 --
72 -- Insert the row into: hxc_mapping_components
73 --
74
75 insert into hxc_mapping_components
76 (mapping_component_id
77 ,field_name
78 ,name
79 ,bld_blk_info_type_id
80 ,segment
81 ,object_version_number
82 ,creation_date
83 ,created_by
84 ,last_updated_by
85 ,last_update_date
86 ,last_update_login
87 )
88 Values
89 (p_rec.mapping_component_id
90 ,p_rec.field_name
91 ,p_rec.name
92 ,p_rec.bld_blk_info_type_id
93 ,p_rec.segment
94 ,p_rec.object_version_number
95 ,sysdate
96 ,fnd_global.user_id
97 ,fnd_global.user_id
98 ,sysdate
99 ,fnd_global.login_id
100 );
101 --
102 hxc_mpc_shd.g_api_dml := false; -- Unset the api dml status
103 --
104 if g_debug then
105 hr_utility.set_location(' Leaving:'||l_proc, 10);
106 end if;
107 Exception
108 When hr_api.check_integrity_violated Then
109 -- A check constraint has been violated
110 hxc_mpc_shd.g_api_dml := false; -- Unset the api dml status
111 hxc_mpc_shd.constraint_error
112 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113 When hr_api.parent_integrity_violated Then
114 -- Parent integrity has been violated
115 hxc_mpc_shd.g_api_dml := false; -- Unset the api dml status
116 hxc_mpc_shd.constraint_error
117 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
118 When hr_api.unique_integrity_violated Then
119 -- Unique integrity has been violated
120 hxc_mpc_shd.g_api_dml := false; -- Unset the api dml status
121 hxc_mpc_shd.constraint_error
122 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
123 When Others Then
124 hxc_mpc_shd.g_api_dml := false; -- Unset the api dml status
125 Raise;
126 End insert_dml;
127 --
128 -- ----------------------------------------------------------------------------
129 -- |------------------------------< pre_insert >------------------------------|
130 -- ----------------------------------------------------------------------------
131 -- {Start Of Comments}
132 --
133 -- Description:
134 -- This private procedure contains any processing which is required before
135 -- the insert dml. Presently, if the entity has a corresponding primary
136 -- key which is maintained by an associating sequence, the primary key for
137 -- the entity will be populated with the next sequence value in
138 -- preparation for the insert dml.
139 --
140 -- Prerequisites:
141 -- This is an internal procedure which is called from the ins procedure.
142 --
143 -- In Parameters:
144 -- A Pl/Sql record structre.
145 --
146 -- Post Success:
147 -- Processing continues.
148 --
149 -- Post Failure:
150 -- If an error has occurred, an error message and exception will be raised
151 -- but not handled.
152 --
153 -- Developer Implementation Notes:
154 -- Any pre-processing required before the insert dml is issued should be
155 -- coded within this procedure. As stated above, a good example is the
156 -- generation of a primary key number via a corresponding sequence.
157 -- It is important to note that any 3rd party maintenance should be reviewed
158 -- before placing in this procedure.
159 --
160 -- Access Status:
161 -- Internal Row Handler Use Only.
162 --
163 -- {End Of Comments}
164 -- ----------------------------------------------------------------------------
165 Procedure pre_insert
166 (p_rec in out nocopy hxc_mpc_shd.g_rec_type
167 ) is
168 --
169 l_proc varchar2(72);
170 --
171 Cursor C_Sel1 is select hxc_mapping_components_s.nextval from sys.dual;
172 --
173 Begin
174
175
176 if g_debug then
177 l_proc := g_package||'pre_insert';
178 hr_utility.set_location('Entering:'||l_proc, 5);
179 end if;
180 --
181 --
182 -- Select the next sequence number
183 --
184 Open C_Sel1;
185 Fetch C_Sel1 Into p_rec.mapping_component_id;
186 Close C_Sel1;
187 --
188 if g_debug then
189 hr_utility.set_location(' Leaving:'||l_proc, 10);
190 end if;
191 End pre_insert;
192 --
193 -- ----------------------------------------------------------------------------
194 -- |-----------------------------< post_insert >------------------------------|
195 -- ----------------------------------------------------------------------------
196 -- {Start Of Comments}
197 --
198 -- Description:
199 -- This private procedure contains any processing which is required after the
200 -- insert dml.
201 --
202 -- Prerequisites:
203 -- This is an internal procedure which is called from the ins procedure.
204 --
205 -- In Parameters:
206 -- A Pl/Sql record structre.
207 --
208 -- Post Success:
209 -- Processing continues.
210 --
211 -- Post Failure:
212 -- If an error has occurred, an error message and exception will be raised
213 -- but not handled.
214 --
215 -- Developer Implementation Notes:
216 -- Any post-processing required after the insert dml is issued should be
217 -- coded within this procedure. It is important to note that any 3rd party
218 -- maintenance should be reviewed before placing in this procedure.
219 --
220 -- Access Status:
221 -- Internal Row Handler Use Only.
222 --
223 -- {End Of Comments}
224 -- ----------------------------------------------------------------------------
225 Procedure post_insert
226 (p_rec in hxc_mpc_shd.g_rec_type
227 ) is
228 --
229 l_proc varchar2(72);
230 --
231 Begin
232
233
234 if g_debug then
235 l_proc := g_package||'post_insert';
236 hr_utility.set_location('Entering:'||l_proc, 5);
237 end if;
238 begin
239 --
240 hxc_mpc_rki.after_insert
241 (p_mapping_component_id
242 => p_rec.mapping_component_id
243 ,p_field_name
244 => p_rec.field_name
245 ,p_name
246 => p_rec.name
247 ,p_bld_blk_info_type_id
248 => p_rec.bld_blk_info_type_id
249 ,p_segment
250 => p_rec.segment
251 ,p_object_version_number
252 => p_rec.object_version_number
253 );
254 --
255 exception
256 --
257 when hr_api.cannot_find_prog_unit then
258 --
259 hr_api.cannot_find_prog_unit_error
260 (p_module_name => 'HXC_MAPPING_COMPONENTS'
261 ,p_hook_type => 'AI');
262 --
263 end;
264 --
265 if g_debug then
266 hr_utility.set_location(' Leaving:'||l_proc, 10);
267 end if;
268 End post_insert;
269 --
270 -- ----------------------------------------------------------------------------
271 -- |---------------------------------< ins >----------------------------------|
272 -- ----------------------------------------------------------------------------
273 Procedure ins
274 (p_rec in out nocopy hxc_mpc_shd.g_rec_type
275 ) is
276 --
277 l_proc varchar2(72);
278 --
279 Begin
280
281 g_debug := hr_utility.debug_enabled;
282
283 if g_debug then
284 l_proc := g_package||'ins';
285 hr_utility.set_location('Entering:'||l_proc, 5);
286 end if;
287 --
288 -- Call the supporting insert validate operations
289 --
290 hxc_mpc_bus.insert_validate
291 (p_rec
292 );
293 --
294 -- Call the supporting pre-insert operation
295 --
296 hxc_mpc_ins.pre_insert(p_rec);
297 --
298 -- Insert the row
299 --
300 hxc_mpc_ins.insert_dml(p_rec);
301 --
302 -- Call the supporting post-insert operation
303 --
304 hxc_mpc_ins.post_insert
305 (p_rec
306 );
307 --
308 if g_debug then
309 hr_utility.set_location('Leaving:'||l_proc, 20);
310 end if;
311 end ins;
312 --
313 -- ----------------------------------------------------------------------------
314 -- |---------------------------------< ins >----------------------------------|
315 -- ----------------------------------------------------------------------------
316 Procedure ins
317 (p_field_name in varchar2 default null
318 ,p_name in varchar2 default null
319 ,p_bld_blk_info_type_id in number default null
320 ,p_segment in varchar2 default null
321 ,p_mapping_component_id out nocopy number
322 ,p_object_version_number out nocopy number
323 ) is
324 --
325 l_rec hxc_mpc_shd.g_rec_type;
326 l_proc varchar2(72);
327 --
328 Begin
329 g_debug := hr_utility.debug_enabled;
330
331 if g_debug then
332 l_proc := g_package||'ins';
333 hr_utility.set_location('Entering:'||l_proc, 5);
334 end if;
335 --
336 -- Call conversion function to turn arguments into the
337 -- p_rec structure.
338 --
339 l_rec :=
340 hxc_mpc_shd.convert_args
341 (null
342 ,p_field_name
343 ,p_name
344 ,p_bld_blk_info_type_id
345 ,p_segment
346 ,null
347 );
348 --
349 -- Having converted the arguments into the hxc_mpc_rec
350 -- plsql record structure we call the corresponding record business process.
351 --
352 hxc_mpc_ins.ins
353 (l_rec
354 );
355 --
356 -- As the primary key argument(s)
357 -- are specified as an OUT's we must set these values.
358 --
359 p_mapping_component_id := l_rec.mapping_component_id;
360 p_object_version_number := l_rec.object_version_number;
361 --
362 if g_debug then
363 hr_utility.set_location(' Leaving:'||l_proc, 10);
364 end if;
365 End ins;
366 --
367 end hxc_mpc_ins;