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