1 Package Body per_ssb_ins as
2 /* $Header: pessbrhi.pkb 115.1 2003/08/06 01:25:57 kavenkat noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_ssb_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_setup_sub_task_code_i per_ri_setup_sub_tasks.setup_sub_task_code%Type default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_setup_sub_task_code in Varchar2) 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_ssb_ins.g_setup_sub_task_code_i := p_setup_sub_task_code;
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_ssb_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_ri_setup_sub_tasks
88 --
89 insert into per_ri_setup_sub_tasks
90 (setup_sub_task_code
91 ,setup_task_code
92 ,setup_sub_task_sequence
93 ,setup_sub_task_status
94 ,setup_sub_task_type
95 ,setup_sub_task_data_pump_link
96 ,setup_sub_task_action
97 ,setup_sub_task_creation_date
98 ,setup_sub_task_last_mod_date
99 ,legislation_code
100 ,object_version_number
101 )
102 Values
103 (p_rec.setup_sub_task_code
104 ,p_rec.setup_task_code
105 ,p_rec.setup_sub_task_sequence
106 ,p_rec.setup_sub_task_status
107 ,p_rec.setup_sub_task_type
108 ,p_rec.setup_sub_task_data_pump_link
109 ,p_rec.setup_sub_task_action
110 ,p_rec.setup_sub_task_creation_date
111 ,p_rec.setup_sub_task_last_mod_date
112 ,p_rec.legislation_code
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_ssb_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_ssb_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_ssb_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_ssb_shd.g_rec_type
179 ) is
180
181 --
182 Cursor C_Sel2 is
183 Select null
184 from per_ri_setup_sub_tasks
185 where setup_sub_task_code =
186 per_ssb_ins.g_setup_sub_task_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_ssb_ins.g_setup_sub_task_code_i is not null) Then
195 --
196 -- Verify registered primary key values not already in use
197 --
198 Open C_Sel2;
199 Fetch C_Sel2 into l_exists;
200 If C_Sel2%found Then
201 Close C_Sel2;
202 --
203 -- The primary key values are already in use.
204 --
205 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
206 fnd_message.set_token('TABLE_NAME','PER_RI_SETUP_SUB_TASKS');
207 fnd_message.raise_error;
208 End If;
209 Close C_Sel2;
210 --
211 -- Use registered key values and clear globals
212 --
213 p_rec.setup_sub_task_code :=
214 per_ssb_ins.g_setup_sub_task_code_i;
215 per_ssb_ins.g_setup_sub_task_code_i := null;
216 Else
217 --
218 -- No registerd key values, so raise error
219 --
220 hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
221 hr_utility.set_message_token('API_NAME', g_package);
222 hr_utility.set_message_token('ARGUMENT', 'SETUP_SUB_TASK_CODE');
223 hr_utility.raise_error;
224
225 End If;
226 --
227 hr_utility.set_location(' Leaving:'||l_proc, 10);
228
229 End pre_insert;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |-----------------------------< post_insert >------------------------------|
233 -- ----------------------------------------------------------------------------
234 -- {Start Of Comments}
235 --
236 -- Description:
237 -- This private procedure contains any processing which is required after
238 -- the insert dml.
239 --
240 -- Prerequisites:
241 -- This is an internal procedure which is called from the ins procedure.
242 --
243 -- In Parameters:
244 -- A Pl/Sql record structre.
245 --
246 -- Post Success:
247 -- Processing continues.
248 --
249 -- Post Failure:
250 -- If an error has occurred, an error message and exception will be raised
251 -- but not handled.
252 --
253 -- Developer Implementation Notes:
254 -- Any post-processing required after the insert dml is issued should be
255 -- coded within this procedure. It is important to note that any 3rd party
256 -- maintenance should be reviewed before placing in this procedure.
257 --
258 -- Access Status:
259 -- Internal Row Handler Use Only.
260 --
261 -- {End Of Comments}
262 -- ----------------------------------------------------------------------------
263 Procedure post_insert
264 (p_effective_date in date
265 ,p_rec in per_ssb_shd.g_rec_type
266 ) is
267 --
268 l_proc varchar2(72) := g_package||'post_insert';
269 --
270 Begin
271 hr_utility.set_location('Entering:'||l_proc, 5);
272 begin
273 --
274 per_ssb_rki.after_insert
275 (p_effective_date => p_effective_date
276 ,p_setup_sub_task_code => p_rec.setup_sub_task_code
277 ,p_setup_task_code => p_rec.setup_task_code
278 ,p_setup_sub_task_sequence => p_rec.setup_sub_task_sequence
279 ,p_setup_sub_task_status => p_rec.setup_sub_task_status
280 ,p_setup_sub_task_type => p_rec.setup_sub_task_type
281 ,p_setup_sub_task_data_pump_lin => p_rec.setup_sub_task_data_pump_link
282 ,p_setup_sub_task_action => p_rec.setup_sub_task_action
283 ,p_setup_sub_task_creation_date => p_rec.setup_sub_task_creation_date
284 ,p_setup_sub_task_last_mod_date => p_rec.setup_sub_task_last_mod_date
285 ,p_legislation_code => p_rec.legislation_code
286 ,p_object_version_number => p_rec.object_version_number
287 );
288 --
289 exception
290 --
291 when hr_api.cannot_find_prog_unit then
292 --
293 hr_api.cannot_find_prog_unit_error
294 (p_module_name => 'PER_RI_SETUP_SUB_TASKS'
295 ,p_hook_type => 'AI');
296 --
297 end;
298 --
299 hr_utility.set_location(' Leaving:'||l_proc, 10);
300 End post_insert;
301 --
302 -- ----------------------------------------------------------------------------
303 -- |---------------------------------< ins >----------------------------------|
304 -- ----------------------------------------------------------------------------
305 Procedure ins
306 (p_effective_date in date
307 ,p_rec in out nocopy per_ssb_shd.g_rec_type
308 ) is
309 --
310 l_proc varchar2(72) := g_package||'ins';
311 --
312 Begin
313 hr_utility.set_location('Entering:'||l_proc, 5);
314 --
315 -- Call the supporting insert validate operations
316 --
317 per_ssb_bus.insert_validate
318 (p_effective_date
319 ,p_rec
320 );
321 --
322 -- Call to raise any errors on multi-message list
323 hr_multi_message.end_validation_set;
324 --
325 -- Call the supporting pre-insert operation
326 --
327 per_ssb_ins.pre_insert(p_rec);
328 --
329 -- Insert the row
330 --
331 per_ssb_ins.insert_dml(p_rec);
332 --
333 -- Call the supporting post-insert operation
334 --
335 per_ssb_ins.post_insert
336 (p_effective_date
337 ,p_rec
338 );
339 --
340 -- Call to raise any errors on multi-message list
341 hr_multi_message.end_validation_set;
342 --
343 hr_utility.set_location('Leaving:'||l_proc, 20);
344 end ins;
345 --
346 -- ----------------------------------------------------------------------------
347 -- |---------------------------------< ins >----------------------------------|
348 -- ----------------------------------------------------------------------------
349 Procedure ins
350 (p_effective_date in date
351 ,p_setup_task_code in varchar2
352 ,p_setup_sub_task_sequence in number
353 ,p_setup_sub_task_data_pump_lin in varchar2
354 ,p_setup_sub_task_status in varchar2 default null
355 ,p_setup_sub_task_type in varchar2 default null
356 ,p_setup_sub_task_action in varchar2 default null
357 ,p_setup_sub_task_creation_date in date default null
358 ,p_setup_sub_task_last_mod_date in date default null
359 ,p_setup_sub_task_code In varchar2
360 ,p_legislation_code In varchar2
361 ,p_object_version_number out nocopy number
362 ) is
363 --
364 l_rec per_ssb_shd.g_rec_type;
365 l_proc varchar2(72) := g_package||'ins';
366 --
367 Begin
368 hr_utility.set_location('Entering:'||l_proc, 5);
369 --
370 -- Call conversion function to turn arguments into the
371 -- p_rec structure.
372 --
373 l_rec :=
374 per_ssb_shd.convert_args
375 (null
376 ,p_setup_task_code
377 ,p_setup_sub_task_sequence
378 ,p_setup_sub_task_status
379 ,p_setup_sub_task_type
380 ,p_setup_sub_task_data_pump_lin
381 ,p_setup_sub_task_action
382 ,p_setup_sub_task_creation_date
383 ,p_setup_sub_task_last_mod_date
384 ,p_legislation_code
385 ,null
386 );
387 --
388 -- Having converted the arguments into the per_ssb_rec
389 -- plsql record structure we call the corresponding record business process.
390 --
391 per_ssb_ins.ins
392 (p_effective_date
393 ,l_rec
394 );
395 --
396 -- As the primary key argument(s)
397 -- are specified as an OUT's we must set these values.
398 --
399
400 p_object_version_number := l_rec.object_version_number;
401 --
402 hr_utility.set_location(' Leaving:'||l_proc, 10);
403 End ins;
404 --
405 end per_ssb_ins;