1 Package Body irc_ita_ins as
2 /* $Header: iritarhi.pkb 120.1 2005/10/04 06:26 kthavran noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' irc_ita_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_template_association_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_template_association_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_ita_ins.g_template_association_id_i := p_template_association_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_ita_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: irc_template_associations
88 --
89 insert into irc_template_associations
90 (template_association_id
91 ,template_id
92 ,default_association
93 ,job_id
94 ,position_id
95 ,organization_id
96 ,start_date
97 ,end_date
98 ,object_version_number
99 )
100 Values
101 (p_rec.template_association_id
102 ,p_rec.template_id
103 ,p_rec.default_association
104 ,p_rec.job_id
105 ,p_rec.position_id
106 ,p_rec.organization_id
107 ,p_rec.start_date
108 ,p_rec.end_date
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 irc_ita_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 irc_ita_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 irc_ita_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 irc_ita_shd.g_rec_type
175 ) is
176 --
177 Cursor C_Sel1 is select irc_template_associations_s.nextval from sys.dual;
178 --
179 Cursor C_Sel2 is
180 Select null
181 from irc_template_associations
182 where template_association_id =
183 irc_ita_ins.g_template_association_id_i;
184 --
185 l_proc varchar2(72) := g_package||'pre_insert';
186 l_exists varchar2(1);
187 --
188 Begin
189 hr_utility.set_location('Entering:'||l_proc, 5);
190 --
191 If (irc_ita_ins.g_template_association_id_i is not null) Then
192 --
193 -- Verify registered primary key values not already in use
194 --
195 Open C_Sel2;
196 Fetch C_Sel2 into l_exists;
197 If C_Sel2%found Then
198 Close C_Sel2;
199 --
200 -- The primary key values are already in use.
201 --
202 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
203 fnd_message.set_token('TABLE_NAME','irc_template_associations');
204 fnd_message.raise_error;
205 End If;
206 Close C_Sel2;
207 --
208 -- Use registered key values and clear globals
209 --
210 p_rec.template_association_id :=
211 irc_ita_ins.g_template_association_id_i;
212 irc_ita_ins.g_template_association_id_i := null;
213 Else
214 --
215 -- No registerd key values, so select the next sequence number
216 --
217 --
218 -- Select the next sequence number
219 --
220 Open C_Sel1;
221 Fetch C_Sel1 Into p_rec.template_association_id;
222 Close C_Sel1;
223 End If;
224 --
225 hr_utility.set_location(' Leaving:'||l_proc, 10);
226 End pre_insert;
227 --
228 -- ----------------------------------------------------------------------------
229 -- |-----------------------------< post_insert >------------------------------|
230 -- ----------------------------------------------------------------------------
231 -- {Start Of Comments}
232 --
233 -- Description:
234 -- This private procedure contains any processing which is required after
235 -- the insert dml.
236 --
237 -- Prerequisites:
238 -- This is an internal procedure which is called from the ins procedure.
239 --
240 -- In Parameters:
241 -- A Pl/Sql record structre.
242 --
243 -- Post Success:
244 -- Processing continues.
245 --
246 -- Post Failure:
247 -- If an error has occurred, an error message and exception will be raised
248 -- but not handled.
249 --
250 -- Developer Implementation Notes:
251 -- Any post-processing required after the insert dml is issued should be
252 -- coded within this procedure. It is important to note that any 3rd party
253 -- maintenance should be reviewed before placing in this procedure.
254 --
255 -- Access Status:
256 -- Internal Row Handler Use Only.
257 --
258 -- {End Of Comments}
259 -- ----------------------------------------------------------------------------
260 Procedure post_insert
261 (p_effective_date in date
262 ,p_rec in irc_ita_shd.g_rec_type
263 ) is
264 --
265 l_proc varchar2(72) := g_package||'post_insert';
266 --
267 Begin
268 hr_utility.set_location('Entering:'||l_proc, 5);
269 begin
270 --
271 irc_ita_rki.after_insert
272 (p_effective_date => p_effective_date
273 ,p_template_association_id
274 => p_rec.template_association_id
275 ,p_template_id
276 => p_rec.template_id
277 ,p_default_association
278 => p_rec.default_association
279 ,p_job_id
280 => p_rec.job_id
281 ,p_position_id
282 => p_rec.position_id
283 ,p_organization_id
284 => p_rec.organization_id
285 ,p_start_date
286 => p_rec.start_date
287 ,p_end_date
288 => p_rec.end_date
289 ,p_object_version_number
290 => p_rec.object_version_number
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_TEMPLATE_ASSOCIATIONS'
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_effective_date in date
311 ,p_rec in out nocopy irc_ita_shd.g_rec_type
312 ) is
313 --
314 l_proc varchar2(72) := g_package||'ins';
315 --
316 Begin
317 hr_utility.set_location('Entering:'||l_proc, 5);
318 --
319 -- Call the supporting insert validate operations
320 --
321 irc_ita_bus.insert_validate
322 (p_effective_date
323 ,p_rec
324 );
325 --
326 -- Call to raise any errors on multi-message list
327 hr_multi_message.end_validation_set;
328 --
329 -- Call the supporting pre-insert operation
330 --
331 irc_ita_ins.pre_insert(p_rec);
332 --
333 -- Insert the row
334 --
335 irc_ita_ins.insert_dml(p_rec);
336 --
337 -- Call the supporting post-insert operation
338 --
339 irc_ita_ins.post_insert
340 (p_effective_date
341 ,p_rec
342 );
343 --
344 -- Call to raise any errors on multi-message list
345 hr_multi_message.end_validation_set;
346 --
347 hr_utility.set_location('Leaving:'||l_proc, 20);
348 end ins;
349 --
350 -- ----------------------------------------------------------------------------
351 -- |---------------------------------< ins >----------------------------------|
352 -- ----------------------------------------------------------------------------
353 Procedure ins
354 (p_effective_date in date
355 ,p_template_id in number
356 ,p_default_association in varchar2 default null
357 ,p_job_id in number default null
358 ,p_position_id in number default null
359 ,p_organization_id in number default null
360 ,p_start_date in date default null
361 ,p_end_date in date default null
362 ,p_template_association_id out nocopy number
363 ,p_object_version_number out nocopy number
364 ) is
365 --
366 l_rec irc_ita_shd.g_rec_type;
367 l_proc varchar2(72) := g_package||'ins';
368 --
369 Begin
370 hr_utility.set_location('Entering:'||l_proc, 5);
371 --
372 -- Call conversion function to turn arguments into the
373 -- p_rec structure.
374 --
375 l_rec :=
376 irc_ita_shd.convert_args
377 (null
378 ,p_template_id
379 ,p_default_association
380 ,p_job_id
381 ,p_position_id
382 ,p_organization_id
383 ,p_start_date
384 ,p_end_date
385 ,null
386 );
387 --
388 -- Having converted the arguments into the irc_ita_rec
389 -- plsql record structure we call the corresponding record business process.
390 --
391 irc_ita_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 p_template_association_id := l_rec.template_association_id;
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 irc_ita_ins;