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