1 Package Body hxc_heg_ins as
2 /* $Header: hxchegrhi.pkb 120.2 2005/09/23 10:42:21 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_heg_ins.'; -- Global package name
9 g_debug boolean :=hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< insert_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 -- Description:
16 -- This procedure controls the actual dml insert logic. The processing of
17 -- this procedure are as follows:
18 -- 1) Initialise the object_version_number to 1 if the object_version_number
19 -- is defined as an attribute for this entity.
20 -- 2) To set and unset the g_api_dml status as required (as we are about to
21 -- perform dml).
22 -- 3) To insert the row into the schema.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Prerequisites:
27 -- This is an internal private procedure which must be called from the ins
28 -- procedure and must have all mandatory attributes set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 -- On the insert dml failure it is important to note that we always reset the
39 -- g_api_dml status to false.
40 -- If a check, unique or parent integrity constraint violation is raised the
41 -- constraint_error procedure will be called.
42 -- If any other error is reported, the error will be raised after the
43 -- g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 -- None.
47 --
48 -- Access Status:
49 -- Internal Row Handler Use Only.
50 --
51 -- ----------------------------------------------------------------------------
52 Procedure insert_dml
53 (p_rec in out nocopy hxc_heg_shd.g_rec_type
54 ) is
55 --
56 l_proc varchar2(72);
57 --
58 Begin
59 if g_debug then
60 l_proc := g_package||'insert_dml';
61 hr_utility.set_location('Entering:'||l_proc, 5);
62 end if;
63 p_rec.object_version_number := 1; -- Initialise the object version
64 --
65 hxc_heg_shd.g_api_dml := true; -- Set the api dml status
66 --
67 -- Insert the row into: hxc_entity_groups
68 --
69 insert into hxc_entity_groups
70 (entity_group_id
71 ,name
72 ,entity_type
73 ,object_version_number
74 ,creation_date
75 ,created_by
76 ,last_updated_by
77 ,last_update_date
78 ,last_update_login
79 ,description
80 ,business_group_id
81 ,legislation_code
82 )
83 Values
84 (p_rec.entity_group_id
85 ,p_rec.name
86 ,p_rec.entity_type
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 ,p_rec.description
94 ,p_rec.business_group_id
95 ,p_rec.legislation_code
96 );
97 --
98 hxc_heg_shd.g_api_dml := false; -- Unset the api dml status
99 --
100 if g_debug then
101 hr_utility.set_location(' Leaving:'||l_proc, 10);
102 end if;
103 Exception
104 When hr_api.check_integrity_violated Then
105 -- A check constraint has been violated
106 hxc_heg_shd.g_api_dml := false; -- Unset the api dml status
107 hxc_heg_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When hr_api.parent_integrity_violated Then
110 -- Parent integrity has been violated
111 hxc_heg_shd.g_api_dml := false; -- Unset the api dml status
112 hxc_heg_shd.constraint_error
113 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
114 When hr_api.unique_integrity_violated Then
115 -- Unique integrity has been violated
116 hxc_heg_shd.g_api_dml := false; -- Unset the api dml status
117 hxc_heg_shd.constraint_error
118 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
119 When Others Then
120 hxc_heg_shd.g_api_dml := false; -- Unset the api dml status
121 Raise;
122 End insert_dml;
123 --
124 -- ----------------------------------------------------------------------------
125 -- |------------------------------< pre_insert >------------------------------|
126 -- ----------------------------------------------------------------------------
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 -- ----------------------------------------------------------------------------
159 Procedure pre_insert
160 (p_rec in out nocopy hxc_heg_shd.g_rec_type
161 ) is
162 --
163 l_proc varchar2(72);
164 --
165 Cursor C_Sel1 is select hxc_entity_groups_s.nextval from sys.dual;
166 --
167 Begin
168 if g_debug then
169 l_proc := g_package||'pre_insert';
170 hr_utility.set_location('Entering:'||l_proc, 5);
171 end if;
172 --
173 --
174 -- Select the next sequence number
175 --
176 Open C_Sel1;
177 Fetch C_Sel1 Into p_rec.entity_group_id;
178 Close C_Sel1;
179 --
180 if g_debug then
181 hr_utility.set_location(' Leaving:'||l_proc, 10);
182 end if;
183 End pre_insert;
184 --
185 -- ----------------------------------------------------------------------------
186 -- |-----------------------------< post_insert >------------------------------|
187 -- ----------------------------------------------------------------------------
188 --
189 -- Description:
190 -- This private procedure contains any processing which is required after the
191 -- insert dml.
192 --
193 -- Prerequisites:
194 -- This is an internal procedure which is called from the ins procedure.
195 --
196 -- In Parameters:
197 -- A Pl/Sql record structre.
198 --
199 -- Post Success:
200 -- Processing continues.
201 --
202 -- Post Failure:
203 -- If an error has occurred, an error message and exception will be raised
204 -- but not handled.
205 --
206 -- Developer Implementation Notes:
207 -- Any post-processing required after the insert dml is issued should be
208 -- coded within this procedure. It is important to note that any 3rd party
209 -- maintenance should be reviewed before placing in this procedure.
210 --
211 -- Access Status:
212 -- Internal Row Handler Use Only.
213 --
214 -- ----------------------------------------------------------------------------
215 Procedure post_insert
216 (p_rec in hxc_heg_shd.g_rec_type
217 ) is
218 --
219 l_proc varchar2(72);
220 --
221 Begin
222 if g_debug then
223 l_proc := g_package||'post_insert';
224 hr_utility.set_location('Entering:'||l_proc, 5);
225 end if;
226 begin
227 --
228 hxc_heg_rki.after_insert
229 (p_entity_group_id
230 => p_rec.entity_group_id
231 ,p_name
232 => p_rec.name
233 ,p_object_version_number
234 => p_rec.object_version_number
235 ,p_description
236 => p_rec.description
237 ,p_business_group_id
238 => p_rec.business_group_id
239 ,p_legislation_code
240 => p_rec.legislation_code
241 );
242 --
243 exception
244 --
245 when hr_api.cannot_find_prog_unit then
246 --
247 hr_api.cannot_find_prog_unit_error
248 (p_module_name => 'HXC_ENTITY_GROUPS'
249 ,p_hook_type => 'AI');
250 --
251 end;
252 --
253 if g_debug then
254 hr_utility.set_location(' Leaving:'||l_proc, 10);
255 end if;
256 End post_insert;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |---------------------------------< ins >----------------------------------|
260 -- ----------------------------------------------------------------------------
261 Procedure ins
262 (p_rec in out nocopy hxc_heg_shd.g_rec_type
263 ) is
264 --
265 l_proc varchar2(72);
266 --
267 Begin
268 g_debug:=hr_utility.debug_enabled;
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_heg_bus.insert_validate
277 (p_rec
278 );
279 --
280 -- Call the supporting pre-insert operation
281 --
282 hxc_heg_ins.pre_insert(p_rec);
283 --
284 -- Insert the row
285 --
286 hxc_heg_ins.insert_dml(p_rec);
287 --
288 -- Call the supporting post-insert operation
289 --
290 hxc_heg_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_entity_type in varchar2
305 ,p_entity_group_id out nocopy number
306 ,p_object_version_number out nocopy number
307 ,p_description in varchar2 default null
308 ,p_business_group_id in number default null
309 ,p_legislation_code in varchar2 default null
310 ) is
311 --
312 l_rec hxc_heg_shd.g_rec_type;
313 l_proc varchar2(72);
314 --
315 Begin
316 g_debug:=hr_utility.debug_enabled;
317 if g_debug then
318 l_proc := g_package||'ins';
319 hr_utility.set_location('Entering:'||l_proc, 5);
320 end if;
321 --
322 -- Call conversion function to turn arguments into the
323 -- p_rec structure.
324 --
325 l_rec :=
326 hxc_heg_shd.convert_args
327 (null
328 ,p_name
329 ,p_entity_type
330 ,null
331 ,p_description
332 ,p_business_group_id
333 ,p_legislation_code
334 );
335 --
336 -- Having converted the arguments into the hxc_heg_rec
337 -- plsql record structure we call the corresponding record business process.
338 --
339 hxc_heg_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_entity_group_id := l_rec.entity_group_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_heg_ins;