1 Package Body irc_cmm_ins as
2 /* $Header: ircmmrhi.pkb 120.2 2008/04/14 14:50:29 amikukum noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' irc_cmm_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_communication_message_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
19 (p_communication_message_id in number) is
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
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_cmm_ins.g_communication_message_id_i := p_communication_message_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_cmm_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_comm_messages
88 --
89 insert into irc_comm_messages
90 (communication_message_id
91 ,parent_id
92 ,communication_topic_id
93 ,message_subject
94 ,message_body
95 ,message_post_date
96 ,sender_type
97 ,sender_id
98 ,document_type
99 ,document_id
100 ,deleted_flag
101 ,object_version_number
102 )
103 Values
104 (p_rec.communication_message_id
105 ,p_rec.parent_id
106 ,p_rec.communication_topic_id
107 ,p_rec.message_subject
108 ,p_rec.message_body
109 ,p_rec.message_post_date
110 ,p_rec.sender_type
111 ,p_rec.sender_id
112 ,p_rec.document_type
113 ,p_rec.document_id
114 ,p_rec.deleted_flag
115 ,p_rec.object_version_number
116 );
117 --
118 --
119 --
120 hr_utility.set_location(' Leaving:'||l_proc, 10);
121 Exception
122 When hr_api.check_integrity_violated Then
123 -- A check constraint has been violated
124 --
125 irc_cmm_shd.constraint_error
126 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127 When hr_api.parent_integrity_violated Then
128 -- Parent integrity has been violated
129 --
130 irc_cmm_shd.constraint_error
131 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132 When hr_api.unique_integrity_violated Then
133 -- Unique integrity has been violated
134 --
135 irc_cmm_shd.constraint_error
136 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
137 When Others Then
138 --
139 Raise;
140 End insert_dml;
141 --
142 -- ----------------------------------------------------------------------------
143 -- |------------------------------< pre_insert >------------------------------|
144 -- ----------------------------------------------------------------------------
145 -- {Start Of Comments}
146 --
147 -- Description:
148 -- This private procedure contains any processing which is required before
149 -- the insert dml. Presently, if the entity has a corresponding primary
150 -- key which is maintained by an associating sequence, the primary key for
151 -- the entity will be populated with the next sequence value in
152 -- preparation for the insert dml.
153 --
154 -- Prerequisites:
155 -- This is an internal procedure which is called from the ins procedure.
156 --
157 -- In Parameters:
158 -- A Pl/Sql record structure.
159 --
160 -- Post Success:
161 -- Processing continues.
162 --
163 -- Post Failure:
164 -- If an error has occurred, an error message and exception will be raised
165 -- but not handled.
166 --
170 -- generation of a primary key number via a corresponding sequence.
167 -- Developer Implementation Notes:
168 -- Any pre-processing required before the insert dml is issued should be
169 -- coded within this procedure. As stated above, a good example is the
171 -- It is important to note that any 3rd party maintenance should be reviewed
172 -- before placing in this procedure.
173 --
174 -- Access Status:
175 -- Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure pre_insert
180 (p_rec in out nocopy irc_cmm_shd.g_rec_type
181 ) is
182 --
183 Cursor C_Sel1 is select irc_comm_messages_s.nextval from sys.dual;
184 --
185 Cursor C_Sel2 is
186 Select null
187 from irc_comm_messages
188 where communication_message_id =
189 irc_cmm_ins.g_communication_message_id_i;
190 --
191 l_proc varchar2(72) := g_package||'pre_insert';
192 l_exists varchar2(1);
193 --
194 Begin
195 hr_utility.set_location('Entering:'||l_proc, 5);
196 --
197 If (irc_cmm_ins.g_communication_message_id_i is not null) Then
198 --
199 -- Verify registered primary key values not already in use
200 --
201 Open C_Sel2;
202 Fetch C_Sel2 into l_exists;
203 If C_Sel2%found Then
204 Close C_Sel2;
205 --
206 -- The primary key values are already in use.
207 --
208 fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
209 fnd_message.set_token('TABLE_NAME','irc_comm_messages');
210 fnd_message.raise_error;
211 End If;
212 Close C_Sel2;
213 --
214 -- Use registered key values and clear globals
215 --
216 p_rec.communication_message_id :=
217 irc_cmm_ins.g_communication_message_id_i;
218 irc_cmm_ins.g_communication_message_id_i := null;
219 Else
220 --
221 -- No registerd key values, so select the next sequence number
222 --
223 --
224 -- Select the next sequence number
225 --
226 Open C_Sel1;
227 Fetch C_Sel1 Into p_rec.communication_message_id;
228 Close C_Sel1;
229 End If;
230 --
231 hr_utility.set_location(' Leaving:'||l_proc, 10);
232 End pre_insert;
233 --
234 -- ----------------------------------------------------------------------------
235 -- |-----------------------------< post_insert >------------------------------|
236 -- ----------------------------------------------------------------------------
237 -- {Start Of Comments}
238 --
239 -- Description:
240 -- This private procedure contains any processing which is required after
241 -- the insert dml.
242 --
243 -- Prerequisites:
244 -- This is an internal procedure which is called from the ins procedure.
245 --
246 -- In Parameters:
247 -- A Pl/Sql record structre.
248 --
249 -- Post Success:
250 -- Processing continues.
251 --
252 -- Post Failure:
253 -- If an error has occurred, an error message and exception will be raised
254 -- but not handled.
255 --
256 -- Developer Implementation Notes:
257 -- Any post-processing required after the insert dml is issued should be
258 -- coded within this procedure. It is important to note that any 3rd party
259 -- maintenance should be reviewed before placing in this procedure.
260 --
261 -- Access Status:
262 -- Internal Row Handler Use Only.
263 --
264 -- {End Of Comments}
265 -- ----------------------------------------------------------------------------
266 Procedure post_insert
267 (p_effective_date in date
268 ,p_rec in irc_cmm_shd.g_rec_type
269 ) is
270 --
271 l_proc varchar2(72) := g_package||'post_insert';
272 --
273 Begin
274 hr_utility.set_location('Entering:'||l_proc, 5);
275 begin
276 --
277 irc_cmm_rki.after_insert
278 (p_effective_date => p_effective_date
279 ,p_communication_message_id
280 => p_rec.communication_message_id
281 ,p_parent_id
282 => p_rec.parent_id
283 ,p_communication_topic_id
284 => p_rec.communication_topic_id
285 ,p_message_subject
286 => p_rec.message_subject
287 ,p_message_body
288 => p_rec.message_body
289 ,p_message_post_date
290 => p_rec.message_post_date
291 ,p_sender_type
292 => p_rec.sender_type
293 ,p_sender_id
294 => p_rec.sender_id
295 ,p_document_type
296 => p_rec.document_type
297 ,p_document_id
298 => p_rec.document_id
299 ,p_deleted_flag
300 => p_rec.deleted_flag
301 ,p_object_version_number
302 => p_rec.object_version_number
303 );
304 --
305 exception
306 --
307 when hr_api.cannot_find_prog_unit then
308 --
309 hr_api.cannot_find_prog_unit_error
310 (p_module_name => 'IRC_COMM_MESSAGES'
311 ,p_hook_type => 'AI');
312 --
313 end;
314 --
315 hr_utility.set_location(' Leaving:'||l_proc, 10);
316 End post_insert;
317 --
318 -- ----------------------------------------------------------------------------
319 -- |---------------------------------< ins >----------------------------------|
320 -- ----------------------------------------------------------------------------
321 Procedure ins
322 (p_effective_date in date
323 ,p_rec in out nocopy irc_cmm_shd.g_rec_type
324 ) is
325 --
326 l_proc varchar2(72) := g_package||'ins';
327 --
328 Begin
329 hr_utility.set_location('Entering:'||l_proc, 5);
330 --
331 -- Call the supporting insert validate operations
332 --
333 irc_cmm_bus.insert_validate
334 (p_effective_date
335 ,p_rec
336 );
337 --
338 -- Call to raise any errors on multi-message list
339 hr_multi_message.end_validation_set;
340 --
341 -- Call the supporting pre-insert operation
342 --
343 irc_cmm_ins.pre_insert(p_rec);
344 --
345 -- Insert the row
346 --
347 irc_cmm_ins.insert_dml(p_rec);
348 --
349 -- Call the supporting post-insert operation
350 --
351 irc_cmm_ins.post_insert
352 (p_effective_date
353 ,p_rec
354 );
355 --
356 -- Call to raise any errors on multi-message list
357 hr_multi_message.end_validation_set;
358 --
359 hr_utility.set_location('Leaving:'||l_proc, 20);
360 end ins;
361 --
362 -- ----------------------------------------------------------------------------
363 -- |---------------------------------< ins >----------------------------------|
364 -- ----------------------------------------------------------------------------
365 Procedure ins
366 (p_effective_date in date
367 ,p_communication_topic_id in number
368 ,p_message_subject in varchar2 default null
369 ,p_message_post_date in date
370 ,p_sender_type in varchar2
371 ,p_sender_id in number
372 ,p_parent_id in number default null
373 ,p_message_body in varchar2 default null
374 ,p_document_type in varchar2 default null
375 ,p_document_id in number default null
376 ,p_deleted_flag in varchar2 default null
377 ,p_communication_message_id out nocopy number
378 ,p_object_version_number out nocopy number
379 ) is
380 --
381 l_rec irc_cmm_shd.g_rec_type;
382 l_proc varchar2(72) := g_package||'ins';
383 --
384 Begin
385 hr_utility.set_location('Entering:'||l_proc, 5);
386 --
387 -- Call conversion function to turn arguments into the
388 -- p_rec structure.
389 --
390 l_rec :=
391 irc_cmm_shd.convert_args
392 (null
393 ,p_parent_id
394 ,p_communication_topic_id
395 ,p_message_subject
396 ,p_message_body
397 ,p_message_post_date
398 ,p_sender_type
399 ,p_sender_id
400 ,p_document_type
401 ,p_document_id
402 ,p_deleted_flag
403 ,null
404 );
405 --
406 -- Having converted the arguments into the irc_cmm_rec
407 -- plsql record structure we call the corresponding record business process.
408 --
409 irc_cmm_ins.ins
410 (p_effective_date
411 ,l_rec
412 );
413 --
414 -- As the primary key argument(s)
415 -- are specified as an OUT's we must set these values.
416 --
417 p_communication_message_id := l_rec.communication_message_id;
418 p_object_version_number := l_rec.object_version_number;
419 --
420 hr_utility.set_location(' Leaving:'||l_proc, 10);
421 End ins;
422 --
423 end irc_cmm_ins;