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