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