1 Package Body per_env_ins as
2 /* $Header: peenvrhi.pkb 120.1 2005/08/04 03:23:12 vegopala noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_env_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_cal_entry_value_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_cal_entry_value_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 per_env_ins.g_cal_entry_value_id_i := p_cal_entry_value_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 set and unset the g_api_dml status as required (as we are about to
43 -- perform dml).
44 -- 3) To insert the row into the schema.
45 -- 4) To trap any constraint violations that may have occurred.
46 -- 5) To raise any other errors.
47 --
48 -- Prerequisites:
49 -- This is an internal private procedure which must be called from the ins
50 -- procedure and must have all mandatory attributes set (except the
51 -- object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 -- A Pl/Sql record structre.
55 --
56 -- Post Success:
57 -- The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 -- On the insert dml failure it is important to note that we always reset the
61 -- g_api_dml status to false.
62 -- If a check, unique or parent integrity constraint violation is raised the
63 -- constraint_error procedure will be called.
64 -- If any other error is reported, the error will be raised after the
65 -- g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 -- None.
69 --
70 -- Access Status:
71 -- Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76 (p_rec in out nocopy per_env_shd.g_rec_type
77 ) is
78 --
79 l_proc varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82 hr_utility.set_location('Entering:'||l_proc, 5);
83 p_rec.object_version_number := 1; -- Initialise the object version
84 --
85 --
86 --
87 -- Insert the row into: per_cal_entry_values
88 insert into per_cal_entry_values
89 (cal_entry_value_id
90 ,calendar_entry_id
91 ,hierarchy_node_id
92 ,idvalue
93 ,org_structure_element_id
94 ,organization_id
98 ,identifier_key
95 ,override_name
96 ,override_type
97 ,parent_entry_value_id
99 ,usage_flag
100 ,object_version_number
101 )
102 Values
103 (p_rec.cal_entry_value_id
104 ,p_rec.calendar_entry_id
105 ,p_rec.hierarchy_node_id
106 ,p_rec.value
107 ,p_rec.org_structure_element_id
108 ,p_rec.organization_id
109 ,p_rec.override_name
110 ,p_rec.override_type
111 ,p_rec.parent_entry_value_id
112 ,p_rec.identifier_key
113 ,p_rec.usage_flag
114 ,p_rec.object_version_number
115 );
116 --
117 --
118 --
119 hr_utility.set_location(' Leaving:'||l_proc, 10);
120 Exception
121 When hr_api.check_integrity_violated Then
122 -- A check constraint has been violated
123 --
124 per_env_shd.constraint_error
125 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
126 When hr_api.parent_integrity_violated Then
127 -- Parent integrity has been violated
128 --
129 per_env_shd.constraint_error
130 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
131 When hr_api.unique_integrity_violated Then
132 -- Unique integrity has been violated
133 --
134 per_env_shd.constraint_error
135 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
136 When Others Then
137 --
138 Raise;
139 End insert_dml;
140 --
141 -- ----------------------------------------------------------------------------
142 -- |------------------------------< pre_insert >------------------------------|
143 -- ----------------------------------------------------------------------------
144 -- {Start Of Comments}
145 --
146 -- Description:
147 -- This private procedure contains any processing which is required before
148 -- the insert dml. Presently, if the entity has a corresponding primary
149 -- key which is maintained by an associating sequence, the primary key for
150 -- the entity will be populated with the next sequence value in
151 -- preparation for the insert dml.
152 --
153 -- Prerequisites:
154 -- This is an internal procedure which is called from the ins procedure.
155 --
156 -- In Parameters:
157 -- A Pl/Sql record structure.
158 --
159 -- Post Success:
160 -- Processing continues.
161 --
162 -- Post Failure:
163 -- If an error has occurred, an error message and exception will be raised
164 -- but not handled.
165 --
166 -- Developer Implementation Notes:
167 -- Any pre-processing required before the insert dml is issued should be
168 -- coded within this procedure. As stated above, a good example is the
169 -- generation of a primary key number via a corresponding sequence.
170 -- It is important to note that any 3rd party maintenance should be reviewed
171 -- before placing in this procedure.
172 --
173 -- Access Status:
174 -- Internal Row Handler Use Only.
175 --
176 -- {End Of Comments}
177 -- ----------------------------------------------------------------------------
178 Procedure pre_insert
179 (p_rec in out nocopy per_env_shd.g_rec_type
180 ) is
181 --
182 Cursor C_Sel1 is select per_cal_entry_values_s.nextval from sys.dual;
183 --
184 Cursor C_Sel2 is
185 Select null
186 from per_cal_entry_values
187 where cal_entry_value_id =
188 per_env_ins.g_cal_entry_value_id_i;
189 --
190 l_proc varchar2(72) := g_package||'pre_insert';
191 l_exists varchar2(1);
192 --
193 Begin
194 hr_utility.set_location('Entering:'||l_proc, 5);
195 --
196 If (per_env_ins.g_cal_entry_value_id_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_cal_entry_values');
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.cal_entry_value_id :=
216 per_env_ins.g_cal_entry_value_id_i;
217 per_env_ins.g_cal_entry_value_id_i := null;
218 Else
219 --
220 -- No registerd key values, so select the next sequence number
221 --
222 --
223 -- Select the next sequence number
224 --
225 Open C_Sel1;
226 Fetch C_Sel1 Into p_rec.cal_entry_value_id;
227 Close C_Sel1;
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:
255 -- Developer Implementation Notes:
252 -- If an error has occurred, an error message and exception will be raised
253 -- but not handled.
254 --
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_effective_date in date
267 ,p_rec in per_env_shd.g_rec_type
268 ) is
269 --
270 l_proc varchar2(72) := g_package||'post_insert';
271 --
272 Begin
273 hr_utility.set_location('Entering:'||l_proc, 5);
274 begin
275 --
276 per_env_rki.after_insert
277 (p_effective_date => p_effective_date
278 ,p_cal_entry_value_id => p_rec.cal_entry_value_id
279 ,p_calendar_entry_id => p_rec.calendar_entry_id
280 ,p_hierarchy_node_id => p_rec.hierarchy_node_id
281 ,p_value => p_rec.value
282 ,p_org_structure_element_id => p_rec.org_structure_element_id
283 ,p_organization_id => p_rec.organization_id
284 ,p_override_name => p_rec.override_name
285 ,p_override_type => p_rec.override_type
286 ,p_parent_entry_value_id => p_rec.parent_entry_value_id
287 ,p_usage_flag => p_rec.usage_flag
288 ,p_object_version_number => p_rec.object_version_number
289 );
290 --
291 exception
292 --
293 when hr_api.cannot_find_prog_unit then
294 --
295 hr_api.cannot_find_prog_unit_error
296 (p_module_name => 'PER_CAL_ENTRY_VALUES'
297 ,p_hook_type => 'AI');
298 --
299 end;
300 --
301 hr_utility.set_location(' Leaving:'||l_proc, 10);
302 End post_insert;
303 --
304 -- ----------------------------------------------------------------------------
305 -- |---------------------------------< ins >----------------------------------|
306 -- ----------------------------------------------------------------------------
307 Procedure ins
308 (p_effective_date in date
309 ,p_rec in out nocopy per_env_shd.g_rec_type
310 ) is
311 --
312 l_proc varchar2(72) := g_package||'ins';
313 --
314 Begin
315 hr_utility.set_location('Entering:'||l_proc, 5);
316 --
317 -- Call the supporting insert validate operations
318 --
319 per_env_bus.insert_validate
320 (p_effective_date
321 ,p_rec
322 );
323 --
324 -- Call to raise any errors on multi-message list
325 hr_multi_message.end_validation_set;
326 --
327 -- Call the supporting pre-insert operation
328 --
329 per_env_ins.pre_insert(p_rec);
330 --
331 -- Insert the row
332 --
333 per_env_ins.insert_dml(p_rec);
334 --
335 -- Call the supporting post-insert operation
336 --
337 per_env_ins.post_insert
338 (p_effective_date
339 ,p_rec
340 );
341 --
342 -- Call to raise any errors on multi-message list
343 hr_multi_message.end_validation_set;
344 --
345 hr_utility.set_location('Leaving:'||l_proc, 20);
346 end ins;
347 --
348 -- ----------------------------------------------------------------------------
349 -- |---------------------------------< ins >----------------------------------|
350 -- ----------------------------------------------------------------------------
351 Procedure ins
352 (p_effective_date in date
353 ,p_calendar_entry_id in number
354 ,p_usage_flag in varchar2
355 ,p_hierarchy_node_id in number default null
356 ,p_value in varchar2 default null
357 ,p_org_structure_element_id in number default null
358 ,p_organization_id in number default null
359 ,p_override_name in varchar2 default null
360 ,p_override_type in varchar2 default null
361 ,p_parent_entry_value_id in number default null
362 ,p_identifier_key in varchar2 default null
363 ,p_cal_entry_value_id out nocopy number
364 ,p_object_version_number out nocopy number
365 ) is
366 --
367 l_rec per_env_shd.g_rec_type;
368 l_proc varchar2(72) := g_package||'ins';
369 --
370 Begin
371 hr_utility.set_location('Entering:'||l_proc, 5);
372 --
373 -- Call conversion function to turn arguments into the
374 -- p_rec structure.
375 --
376 l_rec :=
377 per_env_shd.convert_args
378 (null
379 ,p_calendar_entry_id
380 ,p_hierarchy_node_id
381 ,p_value
382 ,p_org_structure_element_id
383 ,p_organization_id
384 ,p_override_name
385 ,p_override_type
386 ,p_parent_entry_value_id
387 ,p_identifier_key
388 ,null
389 ,p_usage_flag
390 );
391 --
392 -- Having converted the arguments into the per_env_rec
393 -- plsql record structure we call the corresponding record business process.
394 --
395 per_env_ins.ins
396 (p_effective_date
397 ,l_rec
398 );
399 --
400 -- As the primary key argument(s)
401 -- are specified as an OUT's we must set these values.
402 --
403 p_cal_entry_value_id := l_rec.cal_entry_value_id;
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_env_ins;