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