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