1 Package Body ff_ffp_ins as
2 /* $Header: ffffprhi.pkb 120.1 2005/10/05 01:51 adkumar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ff_ffp_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_function_id_i number default null;
14 g_sequence_number_i number default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------< set_base_key_value >----------------------------|
18 -- ----------------------------------------------------------------------------
19 procedure set_base_key_value
20 (p_function_id in number
21 ,p_sequence_number in number) is
22 --
23 l_proc varchar2(72) := g_package||'set_base_key_value';
24 --
25 Begin
26 hr_utility.set_location('Entering:'||l_proc, 10);
27 --
28 ff_ffp_ins.g_function_id_i := p_function_id;
29 ff_ffp_ins.g_sequence_number_i := p_sequence_number;
30 --
31 hr_utility.set_location(' Leaving:'||l_proc, 20);
32 End set_base_key_value;
33 --
34 --
35 -- ----------------------------------------------------------------------------
36 -- |------------------------------< insert_dml >------------------------------|
37 -- ----------------------------------------------------------------------------
38 -- {Start Of Comments}
39 --
40 -- Description:
41 -- This procedure controls the actual dml insert logic. The processing of
42 -- this procedure are as follows:
43 -- 1) Initialise the object_version_number to 1 if the object_version_number
44 -- is defined as an attribute for this entity.
45 -- 2) To set and unset the g_api_dml status as required (as we are about to
46 -- perform dml).
47 -- 3) To insert the row into the schema.
48 -- 4) To trap any constraint violations that may have occurred.
49 -- 5) 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 -- On the insert dml failure it is important to note that we always reset the
64 -- g_api_dml status to false.
65 -- If a check, unique or parent integrity constraint violation is raised the
66 -- constraint_error procedure will be called.
67 -- If any other error is reported, the error will be raised after the
68 -- g_api_dml status is reset.
69 --
70 -- Developer Implementation Notes:
71 -- None.
72 --
73 -- Access Status:
74 -- Internal Row Handler Use Only.
75 --
76 -- {End Of Comments}
77 -- ----------------------------------------------------------------------------
78 Procedure insert_dml
79 (p_rec in out nocopy ff_ffp_shd.g_rec_type
80 ) is
81 --
82 l_proc varchar2(72) := g_package||'insert_dml';
83 --
84 Begin
85 hr_utility.set_location('Entering:'||l_proc, 5);
86 p_rec.object_version_number := 1; -- Initialise the object version
87 --
88 ff_ffp_shd.g_api_dml := true; -- Set the api dml status
89 --
90 -- Insert the row into: ff_function_parameters
91 --
92 insert into ff_function_parameters
93 (function_id
94 ,sequence_number
95 ,class
96 ,continuing_parameter
97 ,data_type
98 ,name
99 ,optional
100 ,object_version_number
101 )
102 Values
103 (p_rec.function_id
104 ,p_rec.sequence_number
105 ,p_rec.class
106 ,p_rec.continuing_parameter
107 ,p_rec.data_type
108 ,p_rec.name
109 ,p_rec.optional
110 ,p_rec.object_version_number
111 );
112 --
113 ff_ffp_shd.g_api_dml := false; -- Unset the api dml status
114 --
115 hr_utility.set_location(' Leaving:'||l_proc, 10);
116 Exception
117 When hr_api.check_integrity_violated Then
118 -- A check constraint has been violated
119 ff_ffp_shd.g_api_dml := false; -- Unset the api dml status
120 ff_ffp_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 ff_ffp_shd.g_api_dml := false; -- Unset the api dml status
125 ff_ffp_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 ff_ffp_shd.g_api_dml := false; -- Unset the api dml status
130 ff_ffp_shd.constraint_error
131 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132 When Others Then
133 ff_ffp_shd.g_api_dml := false; -- Unset the api dml status
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 ff_ffp_shd.g_rec_type
176 ) is
177 --
178 Cursor C_Sel1 is
179 select nvl(max(sequence_number) + 1, 1)
180 from ff_function_parameters
181 where function_id = p_rec.function_id;
182 --
183 Cursor C_Sel2 is
184 Select null
185 from ff_function_parameters
186 where function_id =
187 ff_ffp_ins.g_function_id_i
188 or sequence_number =
189 ff_ffp_ins.g_sequence_number_i;
190 --
191 l_proc varchar2(72) := g_package||'pre_insert';
192 l_exists varchar2(1);
193 --
194 Begin
195 hr_utility.set_location('Entering:'||l_proc, 5);
196 --
197 If (ff_ffp_ins.g_function_id_i is not null or
198 ff_ffp_ins.g_sequence_number_i is not null) Then
199 --
200 -- Verify registered primary key values not already in use
201 --
202 Open C_Sel2;
203 Fetch C_Sel2 into l_exists;
204 If C_Sel2%found Then
205 Close C_Sel2;
206 --
207 -- The primary key values are already in use.
208 --
209 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
210 fnd_message.set_token('TABLE_NAME','ff_function_parameters');
211 fnd_message.raise_error;
212 End If;
213 Close C_Sel2;
214 --
215 -- Use registered key values and clear globals
216 --
217 p_rec.function_id :=
218 ff_ffp_ins.g_function_id_i;
219 ff_ffp_ins.g_function_id_i := null;
220 p_rec.sequence_number :=
221 ff_ffp_ins.g_sequence_number_i;
222 ff_ffp_ins.g_sequence_number_i := null;
223 Else
224 --
225 -- No registerd key values, so select the next sequence number
226 --
227 --
228 -- Select the next sequence number
229 --
230 Open C_Sel1;
231 Fetch C_Sel1 Into p_rec.sequence_number;
232 Close C_Sel1;
233 End If;
234 --
235 hr_utility.set_location(' Leaving:'||l_proc, 10);
236 End pre_insert;
237 --
238 -- ----------------------------------------------------------------------------
239 -- |-----------------------------< post_insert >------------------------------|
240 -- ----------------------------------------------------------------------------
241 -- {Start Of Comments}
242 --
243 -- Description:
244 -- This private procedure contains any processing which is required after
245 -- the insert dml.
246 --
247 -- Prerequisites:
248 -- This is an internal procedure which is called from the ins procedure.
249 --
250 -- In Parameters:
251 -- A Pl/Sql record structre.
252 --
253 -- Post Success:
254 -- Processing continues.
255 --
256 -- Post Failure:
257 -- If an error has occurred, an error message and exception will be raised
258 -- but not handled.
259 --
260 -- Developer Implementation Notes:
261 -- Any post-processing required after the insert dml is issued should be
262 -- coded within this procedure. It is important to note that any 3rd party
263 -- maintenance should be reviewed before placing in this procedure.
264 --
265 -- Access Status:
266 -- Internal Row Handler Use Only.
267 --
268 -- {End Of Comments}
269 -- ----------------------------------------------------------------------------
270 Procedure post_insert
271 (p_effective_date in date
272 ,p_rec in ff_ffp_shd.g_rec_type
273 ) is
274 --
275 l_proc varchar2(72) := g_package||'post_insert';
276 --
277 Begin
278 hr_utility.set_location('Entering:'||l_proc, 5);
279 begin
280 --
281 ff_ffp_rki.after_insert
282 (p_effective_date => p_effective_date
283 ,p_function_id
284 => p_rec.function_id
285 ,p_sequence_number
286 => p_rec.sequence_number
287 ,p_class
288 => p_rec.class
289 ,p_continuing_parameter
290 => p_rec.continuing_parameter
291 ,p_data_type
292 => p_rec.data_type
293 ,p_name
294 => p_rec.name
295 ,p_optional
296 => p_rec.optional
297 ,p_object_version_number
298 => p_rec.object_version_number
299 );
300 --
301 exception
302 --
303 when hr_api.cannot_find_prog_unit then
304 --
305 hr_api.cannot_find_prog_unit_error
306 (p_module_name => 'FF_FUNCTION_PARAMETERS'
307 ,p_hook_type => 'AI');
308 --
309 end;
310 --
311 hr_utility.set_location(' Leaving:'||l_proc, 10);
312 End post_insert;
313 --
314 -- ----------------------------------------------------------------------------
315 -- |---------------------------------< ins >----------------------------------|
316 -- ----------------------------------------------------------------------------
317 Procedure ins
318 (p_effective_date in date
319 ,p_rec in out nocopy ff_ffp_shd.g_rec_type
320 ) is
321 --
322 l_proc varchar2(72) := g_package||'ins';
323 --
324 Begin
325 hr_utility.set_location('Entering:'||l_proc, 5);
326 --
327 -- Call the supporting insert validate operations
328 --
329 ff_ffp_bus.insert_validate
330 (p_effective_date
331 ,p_rec
332 );
333 --
334 -- Call to raise any errors on multi-message list
335 hr_multi_message.end_validation_set;
336 --
337 -- Call the supporting pre-insert operation
338 --
339 ff_ffp_ins.pre_insert(p_rec);
340 --
341 -- Insert the row
342 --
343 ff_ffp_ins.insert_dml(p_rec);
344 --
345 -- Call the supporting post-insert operation
346 --
347 ff_ffp_ins.post_insert
348 (p_effective_date
349 ,p_rec
350 );
351 --
352 -- Call to raise any errors on multi-message list
353 hr_multi_message.end_validation_set;
354 --
355 hr_utility.set_location('Leaving:'||l_proc, 20);
356 end ins;
357 --
358 -- ----------------------------------------------------------------------------
359 -- |---------------------------------< ins >----------------------------------|
360 -- ----------------------------------------------------------------------------
361 Procedure ins
362 (p_effective_date in date
363 ,p_function_id in number
364 ,p_class in varchar2
365 ,p_continuing_parameter in varchar2
366 ,p_data_type in varchar2
367 ,p_name in varchar2
368 ,p_optional in varchar2
369 ,p_sequence_number out nocopy number
370 ,p_object_version_number out nocopy number
371 ) is
372 --
373 l_rec ff_ffp_shd.g_rec_type;
374 l_proc varchar2(72) := g_package||'ins';
375 --
376 Begin
377 hr_utility.set_location('Entering:'||l_proc, 5);
378 --
379 -- Call conversion function to turn arguments into the
380 -- p_rec structure.
381 --
382 l_rec :=
383 ff_ffp_shd.convert_args
384 (p_function_id
385 ,null
386 ,p_class
387 ,p_continuing_parameter
388 ,p_data_type
389 ,p_name
390 ,p_optional
391 ,null
392 );
393 --
394 -- Having converted the arguments into the ff_ffp_rec
395 -- plsql record structure we call the corresponding record business process.
396 --
397 ff_ffp_ins.ins
398 (p_effective_date
399 ,l_rec
400 );
401 --
402 -- As the primary key argument(s)
403 -- are specified as an OUT's we must set these values.
404 --
405 p_sequence_number := l_rec.sequence_number;
406 p_object_version_number := l_rec.object_version_number;
407 --
408 hr_utility.set_location(' Leaving:'||l_proc, 10);
409 End ins;
410 --
411 end ff_ffp_ins;