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