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