1 Package Body per_scn_ins as
2 /* $Header: pescnrhi.pkb 115.2 2003/08/07 23:57:30 vkonda noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_scn_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_solution_id_i number default null;
14 g_component_name_i varchar2(120) default null;
15 g_solution_type_name_i varchar2(120) default null;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |------------------------< set_base_key_value >----------------------------|
19 -- ----------------------------------------------------------------------------
20 procedure set_base_key_value
21 (p_solution_id in number
22 ,p_component_name in varchar2
23 ,p_solution_type_name 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_scn_ins.g_solution_id_i := p_solution_id;
31 per_scn_ins.g_component_name_i := p_component_name;
32 per_scn_ins.g_solution_type_name_i := p_solution_type_name;
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_scn_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_cmpt_names
94 --
95 insert into per_solution_cmpt_names
96 (solution_id
97 ,component_name
98 ,solution_type_name
99 ,name
100 ,template_file
101 ,object_version_number
102 )
103 Values
104 (p_rec.solution_id
105 ,p_rec.component_name
106 ,p_rec.solution_type_name
107 ,p_rec.name
108 ,EMPTY_BLOB()
109 ,p_rec.object_version_number
110 );
111 --
112 --
113 --
114 hr_utility.set_location(' Leaving:'||l_proc, 10);
115 Exception
116 When hr_api.check_integrity_violated Then
117 -- A check constraint has been violated
118 --
119 per_scn_shd.constraint_error
120 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121 When hr_api.parent_integrity_violated Then
122 -- Parent integrity has been violated
123 --
124 per_scn_shd.constraint_error
125 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126 When hr_api.unique_integrity_violated Then
127 -- Unique integrity has been violated
128 --
129 per_scn_shd.constraint_error
130 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131 When Others Then
132 --
133 Raise;
134 End insert_dml;
135 --
136 -- ----------------------------------------------------------------------------
137 -- |------------------------------< pre_insert >------------------------------|
138 -- ----------------------------------------------------------------------------
139 -- {Start Of Comments}
140 --
141 -- Description:
142 -- This private procedure contains any processing which is required before
143 -- the insert dml. Presently, if the entity has a corresponding primary
144 -- key which is maintained by an associating sequence, the primary key for
145 -- the entity will be populated with the next sequence value in
146 -- preparation for the insert dml.
147 --
148 -- Prerequisites:
149 -- This is an internal procedure which is called from the ins procedure.
150 --
151 -- In Parameters:
152 -- A Pl/Sql record structure.
153 --
154 -- Post Success:
155 -- Processing continues.
156 --
157 -- Post Failure:
158 -- If an error has occurred, an error message and exception will be raised
159 -- but not handled.
160 --
161 -- Developer Implementation Notes:
162 -- Any pre-processing required before the insert dml is issued should be
163 -- coded within this procedure. As stated above, a good example is the
164 -- generation of a primary key number via a corresponding sequence.
165 -- It is important to note that any 3rd party maintenance should be reviewed
166 -- before placing in this procedure.
167 --
168 -- Access Status:
169 -- Internal Row Handler Use Only.
170 --
171 -- {End Of Comments}
172 -- ----------------------------------------------------------------------------
173 Procedure pre_insert
174 (p_rec in out nocopy per_scn_shd.g_rec_type
175 ) is
176 --
177 Cursor C_Sel2 is
178 Select null
179 from per_solution_cmpt_names
180 where solution_id = per_scn_ins.g_solution_id_i
181 and component_name = per_scn_ins.g_component_name_i
182 and solution_type_name = per_scn_ins.g_solution_type_name_i;
183 --
184 l_proc varchar2(72) := g_package||'pre_insert';
185 l_exists varchar2(1);
186 --
187 Begin
188 hr_utility.set_location('Entering:'||l_proc, 5);
189 --
190 If (per_scn_ins.g_solution_id_i is not null or
191 per_scn_ins.g_component_name_i is not null or
192 per_scn_ins.g_solution_type_name_i is not null) Then
193 --
194 -- Verify registered primary key values not already in use
195 --
196 Open C_Sel2;
197 Fetch C_Sel2 into l_exists;
198 If C_Sel2%found Then
199 Close C_Sel2;
200 --
201 -- The primary key values are already in use.
202 --
203 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
204 fnd_message.set_token('TABLE_NAME','per_solution_cmpt_names');
205 fnd_message.raise_error;
206 End If;
207 Close C_Sel2;
208 --
209 -- Use registered key values and clear globals
210 --
211 p_rec.solution_id :=
212 per_scn_ins.g_solution_id_i;
213 per_scn_ins.g_solution_id_i := null;
214 p_rec.component_name :=
215 per_scn_ins.g_component_name_i;
216 per_scn_ins.g_component_name_i := null;
217 p_rec.solution_type_name :=
218 per_scn_ins.g_solution_type_name_i;
219 per_scn_ins.g_solution_type_name_i := null;
220 Else
221 --
222 -- No registerd key values, so raise an error.
223 --
224 hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
225 hr_utility.set_message_token('API_NAME', 'per_scn_ins');
226 hr_utility.set_message_token('ARGUMENT', 'base_key_value');
227 hr_utility.raise_error;
228 End If;
229 --
230 hr_utility.set_location(' Leaving:'||l_proc, 10);
231 End pre_insert;
232 --
233 -- ----------------------------------------------------------------------------
234 -- |-----------------------------< post_insert >------------------------------|
235 -- ----------------------------------------------------------------------------
236 -- {Start Of Comments}
237 --
238 -- Description:
239 -- This private procedure contains any processing which is required after
240 -- the insert dml.
241 --
242 -- Prerequisites:
243 -- This is an internal procedure which is called from the ins procedure.
244 --
245 -- In Parameters:
246 -- A Pl/Sql record structre.
247 --
248 -- Post Success:
249 -- Processing continues.
250 --
251 -- Post Failure:
252 -- If an error has occurred, an error message and exception will be raised
253 -- but not handled.
254 --
255 -- Developer Implementation Notes:
256 -- Any post-processing required after the insert dml is issued should be
257 -- coded within this procedure. It is important to note that any 3rd party
258 -- maintenance should be reviewed before placing in this procedure.
259 --
260 -- Access Status:
261 -- Internal Row Handler Use Only.
262 --
263 -- {End Of Comments}
264 -- ----------------------------------------------------------------------------
265 Procedure post_insert
266 (p_rec in per_scn_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 per_scn_rki.after_insert
276 (p_solution_id
277 => p_rec.solution_id
278 ,p_component_name
279 => p_rec.component_name
280 ,p_solution_type_name
281 => p_rec.solution_type_name
282 ,p_name
283 => p_rec.name
284 ,p_object_version_number
285 => p_rec.object_version_number
286 );
287 --
288 exception
289 --
290 when hr_api.cannot_find_prog_unit then
291 --
292 hr_api.cannot_find_prog_unit_error
293 (p_module_name => 'PER_SOLUTION_CMPT_NAMES'
294 ,p_hook_type => 'AI');
295 --
296 end;
297 --
298 hr_utility.set_location(' Leaving:'||l_proc, 10);
299 End post_insert;
300 --
301 -- ----------------------------------------------------------------------------
302 -- |---------------------------------< ins >----------------------------------|
303 -- ----------------------------------------------------------------------------
304 Procedure ins
305 (p_rec in out nocopy per_scn_shd.g_rec_type
306 ) is
307 --
308 l_proc varchar2(72) := g_package||'ins';
309 --
310 Begin
311 hr_utility.set_location('Entering:'||l_proc, 5);
312 --
313 -- Call the supporting insert validate operations
314 --
315 per_scn_bus.insert_validate
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 per_scn_ins.pre_insert(p_rec);
325 --
326 -- Insert the row
327 --
328 per_scn_ins.insert_dml(p_rec);
329 --
330 -- Call the supporting post-insert operation
331 --
332 per_scn_ins.post_insert
333 (p_rec
334 );
335 --
336 -- Call to raise any errors on multi-message list
337 hr_multi_message.end_validation_set;
338 --
339 hr_utility.set_location('Leaving:'||l_proc, 20);
340 end ins;
341 --
342 -- ----------------------------------------------------------------------------
343 -- |---------------------------------< ins >----------------------------------|
344 -- ----------------------------------------------------------------------------
345 Procedure ins
346 (p_name in varchar2
347 ,p_solution_id out nocopy number
348 ,p_component_name out nocopy varchar2
349 ,p_solution_type_name out nocopy varchar2
350 ,p_object_version_number out nocopy number
351 ) is
352 --
353 l_rec per_scn_shd.g_rec_type;
354 l_proc varchar2(72) := g_package||'ins';
355 --
356 Begin
357 hr_utility.set_location('Entering:'||l_proc, 5);
358 --
359 -- Call conversion function to turn arguments into the
360 -- p_rec structure.
361 --
362 l_rec :=
363 per_scn_shd.convert_args
364 (null
365 ,null
366 ,null
367 ,p_name
368 ,null
369 );
370 --
371 -- Having converted the arguments into the per_scn_rec
372 -- plsql record structure we call the corresponding record business process.
373 --
374 per_scn_ins.ins
375 (l_rec
376 );
377 --
378 -- As the primary key argument(s)
379 -- are specified as an OUT's we must set these values.
380 --
381 p_solution_id := l_rec.solution_id;
382 p_component_name := l_rec.component_name;
383 p_solution_type_name := l_rec.solution_type_name;
384 p_object_version_number := l_rec.object_version_number;
385 --
386 hr_utility.set_location(' Leaving:'||l_proc, 10);
387 End ins;
388 --
389 end per_scn_ins;