1 package body hxc_tbb_ins as
2 /* $Header: hxctbbrhi.pkb 120.6.12010000.1 2008/07/28 11:19:46 appldev ship $ */
3
4 -- --------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- --------------------------------------------------------------------------
7
8 g_package varchar2(33) := ' hxc_tbb_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_tbb_shd.g_rec_type
57 ) is
58
59 l_proc varchar2(72);
60
61 begin
62
63
64
65 if g_debug then
66 l_proc := g_package||'insert_dml';
67 hr_utility.set_location('Entering:'||l_proc, 5);
68 end if;
69 p_rec.object_version_number := 1; -- Initialise the object version
70
71 -- insert the row into: hxc_time_building_blocks
72
73 insert into hxc_time_building_blocks
74 (time_building_block_id
75 ,type
76 ,measure
77 ,unit_of_measure
78 ,start_time
79 ,stop_time
80 ,parent_building_block_id
81 ,parent_building_block_ovn
82 ,scope
83 ,object_version_number
84 ,approval_status
85 ,resource_id
86 ,resource_type
87 ,approval_style_id
88 ,date_from
89 ,date_to
90 ,comment_text
91 ,application_set_id
92 ,data_set_id
93 ,translation_display_key
94 ,creation_date
95 ,created_by
96 ,last_updated_by
97 ,last_update_date
98 ,last_update_login
99 )
100 values
101 (p_rec.time_building_block_id
102 ,p_rec.type
103 ,p_rec.measure
104 ,p_rec.unit_of_measure
105 ,p_rec.start_time
106 ,p_rec.stop_time
107 ,p_rec.parent_building_block_id
108 ,p_rec.parent_building_block_ovn
109 ,p_rec.scope
110 ,p_rec.object_version_number
111 ,p_rec.approval_status
112 ,p_rec.resource_id
113 ,p_rec.resource_type
114 ,p_rec.approval_style_id
115 ,p_rec.date_from
116 ,p_rec.date_to
117 ,p_rec.comment_text
118 ,p_rec.application_set_id
119 ,p_rec.data_set_id
120 ,p_rec.translation_display_key
121 ,sysdate
122 ,fnd_global.user_id
123 ,fnd_global.user_id
124 ,sysdate
125 ,fnd_global.login_id
126 );
127
128 if g_debug then
129 hr_utility.set_location(' Leaving:'||l_proc, 10);
130 end if;
131
132 exception
133 when hr_api.check_integrity_violated then
134 -- a check constraint has been violated
135 hxc_tbb_shd.constraint_error
136 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
137 when hr_api.parent_integrity_violated then
138 -- Parent integrity has been violated
139 hxc_tbb_shd.constraint_error
140 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
141 when hr_api.unique_integrity_violated then
142 -- Unique integrity has been violated
143 hxc_tbb_shd.constraint_error
144 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
145 when others then
146 raise;
147 end insert_dml;
148
149 -- --------------------------------------------------------------------------
150 -- |------------------------------< pre_insert >----------------------------|
151 -- --------------------------------------------------------------------------
152 -- {Start Of Comments}
153 --
154 -- Description:
155 -- This private procedure contains any processing which is required before
156 -- the insert dml. Presently, if the entity has a corresponding primary
157 -- key which is maintained by an associating sequence, the primary key for
158 -- the entity will be populated with the next sequence value in
159 -- preparation for the insert dml.
160 --
161 -- Prerequisites:
162 -- This is an internal procedure which is called from the ins procedure.
163 --
164 -- In Parameters:
165 -- A Pl/Sql record structre.
166 --
167 -- Post Success:
168 -- Processing continues.
169 --
170 -- Post Failure:
171 -- if an error has occurred, an error message and exception will be raised
172 -- but not handled.
173 --
174 -- Developer Implementation Notes:
175 -- Any pre-processing required before the insert dml is issued should be
176 -- coded within this procedure. As stated above, a good example is the
177 -- generation of a primary key number via a corresponding sequence.
178 -- It is important to note that any 3rd party maintenance should be reviewed
179 -- before placing in this procedure.
180 --
181 -- Access Status:
182 -- Internal Row Handler Use Only.
183 --
184 -- {end Of Comments}
185 -- --------------------------------------------------------------------------
186 procedure pre_insert
187 (p_rec in out nocopy hxc_tbb_shd.g_rec_type
188 ) is
189
190 l_proc varchar2(72);
191
192 cursor c_sel1 is select hxc_time_building_blocks_s.nextval from dual;
193
194 begin
195
196
197
198 if g_debug then
199 l_proc := g_package||'pre_insert';
200 hr_utility.set_location('Entering:'||l_proc, 5);
201 end if;
202
203
204 -- select the next sequence number
205
206 open c_sel1;
207 fetch c_sel1 into p_rec.time_building_block_id;
208 close c_sel1;
209
210 if g_debug then
211 hr_utility.set_location(' Leaving:'||l_proc, 10);
212 end if;
213
214 end pre_insert;
215
216 -- --------------------------------------------------------------------------
217 -- |-----------------------------< post_insert >----------------------------|
218 -- --------------------------------------------------------------------------
219 -- {Start Of Comments}
220 --
221 -- Description:
222 -- This private procedure contains any processing which is required after the
223 -- insert dml.
224 --
225 -- Prerequisites:
226 -- This is an internal procedure which is called from the ins procedure.
227 --
228 -- In Parameters:
229 -- A Pl/Sql record structre.
230 --
231 -- Post Success:
232 -- Processing continues.
233 --
234 -- Post Failure:
235 -- if an error has occurred, an error message and exception will be raised
236 -- but not handled.
237 --
238 -- Developer Implementation Notes:
239 -- Any post-processing required after the insert dml is issued should be
240 -- coded within this procedure. It is important to note that any 3rd party
241 -- maintenance should be reviewed before placing in this procedure.
242 --
243 -- Access Status:
244 -- Internal Row Handler Use Only.
245 --
246 -- {end Of Comments}
247 -- --------------------------------------------------------------------------
248 procedure post_insert
249 (p_effective_date in date
250 ,p_rec in hxc_tbb_shd.g_rec_type
251 ) is
252
253 l_proc varchar2(72);
254
255 begin
256
257
258
259 if g_debug then
260 l_proc := g_package||'post_insert';
261 hr_utility.set_location('Entering:'||l_proc, 5);
262 end if;
263 begin
264 /*
265 hxc_tbb_rki.after_insert
266 (p_effective_date
267 => p_effective_date
268 ,p_time_building_block_id
269 => p_rec.time_building_block_id
270 ,p_type
271 => p_rec.type
272 ,p_measure
273 => p_rec.measure
274 ,p_unit_of_measure
275 => p_rec.unit_of_measure
276 ,p_start_time
277 => p_rec.start_time
278 ,p_stop_time
279 => p_rec.stop_time
280 ,p_parent_building_block_id
281 => p_rec.parent_building_block_id
282 ,p_parent_building_block_ovn
283 => p_rec.parent_building_block_ovn
284 ,p_scope
285 => p_rec.scope
286 ,p_object_version_number
287 => p_rec.object_version_number
288 ,p_approval_status
289 => p_rec.approval_status
290 ,p_resource_id
291 => p_rec.resource_id
292 ,p_resource_type
293 => p_rec.resource_type
294 ,p_approval_style_id
295 => p_rec.approval_style_id
296 ,p_date_from
297 => p_rec.date_from
298 ,p_date_to
299 => p_rec.date_to
300 ,p_comment_text
301 => p_rec.comment_text
302 ,p_application_set_id
303 =>p_application_set_id
304 );
305 */null;
306 exception
307 when hr_api.cannot_find_prog_unit then
308 hr_api.cannot_find_prog_unit_error
309 (p_module_name => 'HXC_TIME_BUILDING_BLOCKS'
310 ,p_hook_type => 'AI');
311
312 end;
313
314 if g_debug then
315 hr_utility.set_location(' Leaving:'||l_proc, 10);
316 end if;
317
318 end post_insert;
319
320 -- --------------------------------------------------------------------------
321 -- |---------------------------------< ins >--------------------------------|
322 -- --------------------------------------------------------------------------
323 procedure ins
324 (p_effective_date in date
325 ,p_rec in out nocopy hxc_tbb_shd.g_rec_type
326 ) is
327
328 l_proc varchar2(72);
329
330 begin
331
332 g_debug := hr_utility.debug_enabled;
333
334 if g_debug then
335 l_proc := g_package||'ins';
336 hr_utility.set_location('Entering:'||l_proc, 5);
337 end if;
338
339 -- call the supporting insert validate operations
340
341 hxc_tbb_bus.insert_validate
342 (p_effective_date
343 ,p_rec
344 );
345
346 -- call the supporting pre-insert operation
347
348 hxc_tbb_ins.pre_insert(p_rec);
349
350 -- insert the row
351
352 hxc_tbb_ins.insert_dml(p_rec);
353
354 -- call the supporting post-insert operation
355
356 hxc_tbb_ins.post_insert
357 (p_effective_date
358 ,p_rec
359 );
360
361 if g_debug then
362 hr_utility.set_location('Leaving:'||l_proc, 20);
363 end if;
364
365 end ins;
366
367 -- --------------------------------------------------------------------------
368 -- |---------------------------------< ins >--------------------------------|
369 -- --------------------------------------------------------------------------
370 procedure ins
371 (p_effective_date in date
372 ,p_type in varchar2
373 ,p_scope in varchar2
374 ,p_approval_status in varchar2
375 ,p_measure in number default null
376 ,p_unit_of_measure in varchar2 default null
377 ,p_start_time in date default null
378 ,p_stop_time in date default null
379 ,p_parent_building_block_id in number default null
380 ,p_parent_building_block_ovn in number default null
381 ,p_resource_id in number default null
382 ,p_resource_type in varchar2 default null
383 ,p_approval_style_id in number default null
384 ,p_date_from in date default null
385 ,p_date_to in date default null
386 ,p_comment_text in varchar2 default null
387 ,p_application_set_id in number default null
388 ,p_data_set_id in number default null
389 ,p_translation_display_key in varchar2 default null
390 ,p_time_building_block_id out nocopy number
391 ,p_object_version_number out nocopy number
392 ) is
393
394 l_rec hxc_tbb_shd.g_rec_type;
395 l_proc varchar2(72);
396
397 begin
398 g_debug := hr_utility.debug_enabled;
399
400 if g_debug then
401 l_proc := g_package||'ins';
402 hr_utility.set_location('Entering:'||l_proc, 5);
403 end if;
404
405 -- call conversion function to turn arguments into the
406 -- p_rec structure.
407
408 l_rec :=
409 hxc_tbb_shd.convert_args
410 (null
411 ,p_type
412 ,p_measure
413 ,p_unit_of_measure
414 ,p_start_time
415 ,p_stop_time
416 ,p_parent_building_block_id
417 ,p_parent_building_block_ovn
418 ,p_scope
419 ,null
420 ,p_approval_status
421 ,p_resource_id
422 ,p_resource_type
423 ,p_approval_style_id
424 ,p_date_from
425 ,p_date_to
426 ,p_comment_text
427 ,p_application_set_id
428 ,p_data_set_id
429 ,p_translation_display_key
430 );
431
432 -- having converted the arguments into the hxc_tbb_rec
433 -- plsql record structure we call the corresponding record business process.
434
435 hxc_tbb_ins.ins
436 (p_effective_date
437 ,l_rec
438 );
439
440 -- as the primary key argument is specified as an out,
441 -- we must set this value
442
443 p_time_building_block_id := l_rec.time_building_block_id;
444 p_object_version_number := l_rec.object_version_number;
445
446 if g_debug then
447 hr_utility.set_location(' Leaving:'||l_proc, 10);
448 end if;
449
450 end ins;
451
452 end hxc_tbb_ins;