1 Package Body hxc_htc_ins as
2 /* $Header: hxchtcrhi.pkb 120.3 2007/10/19 11:54:08 anuthi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_htc_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_htc_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_htc_shd.g_api_dml := true; -- Set the api dml status
71 --
72 -- Insert the row into: hxc_time_categories
73 --
74 insert into hxc_time_categories
75 (time_category_id
76 ,time_category_name
77 ,operator
78 ,description
79 ,display
80 ,object_version_number
81 ,creation_date
82 ,created_by
83 ,last_updated_by
84 ,last_update_date
85 ,last_update_login)
86 Values
87 (p_rec.time_category_id
88 ,p_rec.time_category_name
89 ,p_rec.operator
90 ,p_rec.description
91 ,p_rec.display
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 hxc_htc_shd.g_api_dml := false; -- Unset the api dml status
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 hxc_htc_shd.g_api_dml := false; -- Unset the api dml status
109 hxc_htc_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 hxc_htc_shd.g_api_dml := false; -- Unset the api dml status
114 hxc_htc_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 hxc_htc_shd.g_api_dml := false; -- Unset the api dml status
119 hxc_htc_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When Others Then
122 hxc_htc_shd.g_api_dml := false; -- Unset the api dml status
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_htc_shd.g_rec_type
165 ) is
166 --
167 l_proc varchar2(72);
168 --
169 Cursor C_Sel1 is select hxc_time_categories_s.nextval from sys.dual;
170 --
171 Begin
172
173
174 if g_debug then
175 l_proc := g_package||'pre_insert';
176 hr_utility.set_location('Entering:'||l_proc, 5);
177 end if;
178 --
179 --
180 -- Select the next sequence number
181 --
182 Open C_Sel1;
183 Fetch C_Sel1 Into p_rec.time_category_id;
184 Close C_Sel1;
185 --
186 if g_debug then
187 hr_utility.set_location(' Leaving:'||l_proc, 10);
188 end if;
189 End pre_insert;
190 --
191 -- ----------------------------------------------------------------------------
192 -- |-----------------------------< post_insert >------------------------------|
193 -- ----------------------------------------------------------------------------
194 -- {Start Of Comments}
195 --
196 -- Description:
197 -- This private procedure contains any processing which is required after the
198 -- insert dml.
199 --
200 -- Prerequisites:
201 -- This is an internal procedure which is called from the ins procedure.
202 --
203 -- In Parameters:
204 -- A Pl/Sql record structre.
205 --
206 -- Post Success:
207 -- Processing continues.
208 --
209 -- Post Failure:
210 -- If an error has occurred, an error message and exception will be raised
211 -- but not handled.
212 --
213 -- Developer Implementation Notes:
214 -- Any post-processing required after the insert dml is issued should be
215 -- coded within this procedure. It is important to note that any 3rd party
216 -- maintenance should be reviewed before placing in this procedure.
217 --
218 -- Access Status:
219 -- Internal Row Handler Use Only.
220 --
221 -- {End Of Comments}
222 -- ----------------------------------------------------------------------------
223 Procedure post_insert
224 (p_rec in hxc_htc_shd.g_rec_type
225 ) is
226 --
227 l_proc varchar2(72);
228 --
229 Begin
230
231
232 if g_debug then
233 l_proc := g_package||'post_insert';
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 end if;
236 begin
237 --
238 hxc_htc_rki.after_insert
239 (p_time_category_id
240 => p_rec.time_category_id
241 ,p_time_category_name
242 => p_rec.time_category_name
243 ,p_operator => p_rec.operator
244 ,p_description => p_rec.description
245 ,p_display => p_rec.display
246 ,p_object_version_number
247 => p_rec.object_version_number
248 );
249 --
250 exception
251 --
252 when hr_api.cannot_find_prog_unit then
253 --
254 hr_api.cannot_find_prog_unit_error
255 (p_module_name => 'HXC_TIME_CATEGORIES'
256 ,p_hook_type => 'AI');
257 --
258 end;
259 --
260 if g_debug then
261 hr_utility.set_location(' Leaving:'||l_proc, 10);
262 end if;
263 End post_insert;
264 --
265 -- ----------------------------------------------------------------------------
266 -- |---------------------------------< ins >----------------------------------|
267 -- ----------------------------------------------------------------------------
268 Procedure ins
269 (p_rec in out nocopy hxc_htc_shd.g_rec_type
270 ) is
271 --
272 l_proc varchar2(72);
273 --
274 Begin
275 g_debug := hr_utility.debug_enabled;
276
277 if g_debug then
278 l_proc := g_package||'ins';
279 hr_utility.set_location('Entering:'||l_proc, 5);
280 end if;
281 --
282 -- Call the supporting insert validate operations
283 --
284 hxc_htc_bus.insert_validate
285 (p_rec
286 );
287 --
288 -- Call the supporting pre-insert operation
289 --
290 hxc_htc_ins.pre_insert(p_rec);
291 --
292 -- Insert the row
293 --
294 hxc_htc_ins.insert_dml(p_rec);
295 --
296 -- Call the supporting post-insert operation
297 --
298 hxc_htc_ins.post_insert
299 (p_rec
300 );
301 --
302 if g_debug then
303 hr_utility.set_location('Leaving:'||l_proc, 20);
304 end if;
305 end ins;
306 --
307 -- ----------------------------------------------------------------------------
308 -- |---------------------------------< ins >----------------------------------|
309 -- ----------------------------------------------------------------------------
310 Procedure ins
311 (p_time_category_name in varchar2
312 ,p_operator in varchar2
313 ,p_description in varchar2
314 ,p_display in varchar2
315 ,p_time_category_id out nocopy number
316 ,p_object_version_number out nocopy number
317 ) is
318 --
319 l_rec hxc_htc_shd.g_rec_type;
320 l_proc varchar2(72);
321 --
322 Begin
323 g_debug := hr_utility.debug_enabled;
324
325 if g_debug then
326 l_proc := g_package||'ins';
327 hr_utility.set_location('Entering:'||l_proc, 5);
328 end if;
329 --
330 -- Call conversion function to turn arguments into the
331 -- p_rec structure.
332 --
333
334 l_rec :=
335 hxc_htc_shd.convert_args
336 (null
337 ,p_time_category_name
338 ,p_operator
339 ,p_description
340 ,p_display
341 ,null
342 );
343 --
344 -- Having converted the arguments into the hxc_htc_rec
345 -- plsql record structure we call the corresponding record business process.
346 --
347 hxc_htc_ins.ins
348 (l_rec
349 );
350 --
351 -- As the primary key argument(s)
352 -- are specified as an OUT's we must set these values.
353 --
354 p_time_category_id := l_rec.time_category_id;
355 p_object_version_number := l_rec.object_version_number;
356 --
357 if g_debug then
358 hr_utility.set_location(' Leaving:'||l_proc, 10);
359 end if;
360 End ins;
361 --
362 end hxc_htc_ins;