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