1 Package Body irc_ias_ins as
2 /* $Header: iriasrhi.pkb 120.5 2011/02/16 12:43:23 vmummidi noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' irc_ias_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_assignment_status_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_assignment_status_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 irc_ias_ins.g_assignment_status_id_i := p_assignment_status_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 irc_ias_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 irc_ias_shd.g_api_dml := true; -- Set the api dml status
86 --
87 -- Insert the row into: irc_assignment_statuses
88 --
89 insert into irc_assignment_statuses
90 (assignment_status_id
91 ,assignment_id
92 ,status_change_reason
93 ,object_version_number
94 ,assignment_status_type_id
95 ,status_change_date
96 ,status_change_comments
97 ,status_change_by
98 )
99 Values
100 (p_rec.assignment_status_id
101 ,p_rec.assignment_id
102 ,p_rec.status_change_reason
103 ,p_rec.object_version_number
104 ,p_rec.assignment_status_type_id
105 ,p_rec.status_change_date
106 ,p_rec.status_change_comments
107 ,p_rec.status_change_by
108 );
109 --
110 irc_ias_shd.g_api_dml := false; -- Unset the api dml status
111 --
112 hr_utility.set_location(' Leaving:'||l_proc, 10);
113 Exception
114 When hr_api.check_integrity_violated Then
115 -- A check constraint has been violated
116 irc_ias_shd.g_api_dml := false; -- Unset the api dml status
117 --
118 irc_ias_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When hr_api.parent_integrity_violated Then
121 -- Parent integrity has been violated
122 irc_ias_shd.g_api_dml := false; -- Unset the api dml status
123 --
124 irc_ias_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 irc_ias_shd.g_api_dml := false; -- Unset the api dml status
129 --
130 irc_ias_shd.constraint_error
131 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132 When Others Then
133 --
134 irc_ias_shd.g_api_dml := false; -- Unset the api dml status
135 --
136 Raise;
137 End insert_dml;
138 --
139 -- ----------------------------------------------------------------------------
140 -- |------------------------------< pre_insert >------------------------------|
141 -- ----------------------------------------------------------------------------
142 -- {Start Of Comments}
143 --
144 -- Description:
145 -- This private procedure contains any processing which is required before
146 -- the insert dml. Presently, if the entity has a corresponding primary
147 -- key which is maintained by an associating sequence, the primary key for
148 -- the entity will be populated with the next sequence value in
149 -- preparation for the insert dml.
150 --
151 -- Prerequisites:
152 -- This is an internal procedure which is called from the ins procedure.
153 --
154 -- In Parameters:
155 -- A Pl/Sql record structure.
156 --
157 -- Post Success:
158 -- Processing continues.
159 --
160 -- Post Failure:
161 -- If an error has occurred, an error message and exception will be raised
162 -- but not handled.
163 --
164 -- Developer Implementation Notes:
165 -- Any pre-processing required before the insert dml is issued should be
166 -- coded within this procedure. As stated above, a good example is the
167 -- generation of a primary key number via a corresponding sequence.
168 -- It is important to note that any 3rd party maintenance should be reviewed
169 -- before placing in this procedure.
170 --
171 -- Access Status:
172 -- Internal Row Handler Use Only.
173 --
174 -- {End Of Comments}
175 -- ----------------------------------------------------------------------------
176 Procedure pre_insert
177 (p_rec in out nocopy irc_ias_shd.g_rec_type
178 ) is
179 --
180 Cursor C_Sel1 is select irc_assignment_statuses_s.nextval from sys.dual;
181 --
182 Cursor C_Sel2 is
183 Select null
184 from irc_assignment_statuses
185 where assignment_status_id =
186 irc_ias_ins.g_assignment_status_id_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 (irc_ias_ins.g_assignment_status_id_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','irc_assignment_statuses');
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.assignment_status_id :=
214 irc_ias_ins.g_assignment_status_id_i;
215 irc_ias_ins.g_assignment_status_id_i := null;
216 Else
217 --
218 -- No registerd key values, so select the next sequence number
219 --
220 --
221 -- Select the next sequence number
222 --
223 Open C_Sel1;
224 Fetch C_Sel1 Into p_rec.assignment_status_id;
225 Close C_Sel1;
226 End If;
227 --
228 hr_utility.set_location(' Leaving:'||l_proc, 10);
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_rec in irc_ias_shd.g_rec_type
265 ) is
266 --
267 l_proc varchar2(72) := g_package||'post_insert';
268 --
269 Begin
270 hr_utility.set_location('Entering:'||l_proc, 5);
271 begin
272 --
273 irc_ias_rki.after_insert
274 (
275 p_assignment_status_id
276 => p_rec.assignment_status_id
277 ,p_assignment_id
278 => p_rec.assignment_id
279 ,p_status_change_reason
280 => p_rec.status_change_reason
281 ,p_object_version_number
282 => p_rec.object_version_number
283 ,p_assignment_status_type_id
284 => p_rec.assignment_status_type_id
285 ,p_status_change_date
286 => p_rec.status_change_date
287 ,p_status_change_comments
288 => p_rec.status_change_comments
289 ,p_status_change_by
290 => p_rec.status_change_by
291 );
292 --
293 exception
294 --
295 when hr_api.cannot_find_prog_unit then
296 --
297 hr_api.cannot_find_prog_unit_error
298 (p_module_name => 'IRC_ASSIGNMENT_STATUSES'
299 ,p_hook_type => 'AI');
300 --
301 end;
302 --
303 hr_utility.set_location(' Leaving:'||l_proc, 10);
304 End post_insert;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< ins >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure ins
310 ( p_rec in out nocopy irc_ias_shd.g_rec_type
311 ) is
312 --
313 l_proc varchar2(72) := g_package||'ins';
314 --
315 Begin
316 hr_utility.set_location('Entering:'||l_proc, 5);
317 --
318 -- Call the supporting insert validate operations
319 --
320 irc_ias_bus.insert_validate (p_rec);
321 --
322 -- Call to raise any errors on multi-message list
323 hr_multi_message.end_validation_set;
324 -- Call the supporting pre-insert operation
325 --
326 irc_ias_ins.pre_insert(p_rec);
327 --
328 -- Insert the row
329 --
330 irc_ias_ins.insert_dml(p_rec);
331 --
332 -- Call the supporting post-insert operation
333 --
334 irc_ias_ins.post_insert (p_rec );
335 --
336 -- Call to raise any errors on multi-message list
337 hr_multi_message.end_validation_set;
338 hr_utility.set_location('Leaving:'||l_proc, 20);
339 end ins;
340 --
341 -- ----------------------------------------------------------------------------
342 -- |---------------------------------< ins >----------------------------------|
343 -- ----------------------------------------------------------------------------
344 Procedure ins
345 (
346 p_assignment_id in number
347 ,p_assignment_status_type_id in number
348 ,p_status_change_reason in varchar2 default null
349 ,p_status_change_date in date
350 ,p_status_change_comments in varchar2 default null
351 ,p_status_change_by in varchar2 default null
352 ,p_assignment_status_id out nocopy number
353 ,p_object_version_number out nocopy number
354 ) is
355 --
356 l_rec irc_ias_shd.g_rec_type;
357 l_proc varchar2(72) := g_package||'ins';
358 --
359 Begin
360 hr_utility.set_location('Entering:'||l_proc, 5);
361 --
362 -- Call conversion function to turn arguments into the
363 -- p_rec structure.
364 --
365 l_rec :=
366 irc_ias_shd.convert_args
367 (null
368 ,p_assignment_id
369 ,p_status_change_reason
370 ,null
371 ,p_assignment_status_type_id
372 ,p_status_change_date
373 ,p_status_change_comments
374 ,p_status_change_by
375 );
376 --
377 -- Having converted the arguments into the irc_ias_rec
378 -- plsql record structure we call the corresponding record business process.
379 --
380 irc_ias_ins.ins(l_rec );
381 --
382 -- As the primary key argument(s)
383 -- are specified as an OUT's we must set these values.
384 --
385 p_assignment_status_id := l_rec.assignment_status_id;
386 p_object_version_number := l_rec.object_version_number;
387 --
388 hr_utility.set_location(' Leaving:'||l_proc, 10);
389 End ins;
390 --
391 end irc_ias_ins;