1 Package Body ota_fms_ins as
2 /* $Header: otfmsrhi.pkb 120.0 2005/06/24 07:54 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_fms_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_forum_message_id_i number default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19 (p_forum_message_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 ota_fms_ins.g_forum_message_id_i := p_forum_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 ota_fms_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: ota_forum_messages
88 --
89 insert into ota_forum_messages
90 (forum_message_id
91 ,forum_id
92 ,forum_thread_id
93 ,business_group_id
94 ,message_body
95 ,parent_message_id
96 ,person_id
97 ,contact_id
98 ,target_person_id
99 ,target_contact_id
100 ,message_scope
101 ,object_version_number
102 )
103 Values
104 (p_rec.forum_message_id
105 ,p_rec.forum_id
106 ,p_rec.forum_thread_id
107 ,p_rec.business_group_id
108 ,p_rec.message_body
109 ,p_rec.parent_message_id
110 ,p_rec.person_id
111 ,p_rec.contact_id
112 ,p_rec.target_person_id
113 ,p_rec.target_contact_id
114 ,p_rec.message_scope
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 ota_fms_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 ota_fms_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 ota_fms_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 --
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
170 -- generation of a primary key number via a corresponding sequence.
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 ota_fms_shd.g_rec_type
181 ) is
182 --
183 Cursor C_Sel1 is select ota_forum_messages_s.nextval from sys.dual;
184 --
185 Cursor C_Sel2 is
186 Select null
187 from ota_forum_messages
188 where forum_message_id =
189 ota_fms_ins.g_forum_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 (ota_fms_ins.g_forum_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','ota_forum_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.forum_message_id :=
217 ota_fms_ins.g_forum_message_id_i;
218 ota_fms_ins.g_forum_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.forum_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 ota_fms_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 ota_fms_rki.after_insert
278 (p_effective_date => p_effective_date
279 ,p_forum_message_id
280 => p_rec.forum_message_id
281 ,p_forum_id
282 => p_rec.forum_id
283 ,p_forum_thread_id
284 => p_rec.forum_thread_id
285 ,p_business_group_id
286 => p_rec.business_group_id
287 ,p_message_body
288 => p_rec.message_body
289 ,p_parent_message_id
290 => p_rec.parent_message_id
291 ,p_person_id
292 => p_rec.person_id
293 ,p_contact_id
294 => p_rec.contact_id
295 ,p_target_person_id
296 => p_rec.target_person_id
297 ,p_target_contact_id
298 => p_rec.target_contact_id
299 ,p_message_scope
300 => p_rec.message_scope
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 => 'OTA_FORUM_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 ota_fms_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 ota_fms_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 ota_fms_ins.pre_insert(p_rec);
344 --
345 -- Insert the row
346 --
347 ota_fms_ins.insert_dml(p_rec);
348 --
349 -- Call the supporting post-insert operation
350 --
351 ota_fms_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_forum_id in number
368 ,p_forum_thread_id in number
369 ,p_business_group_id in number
370 ,p_message_scope in varchar2
371 ,p_message_body in varchar2 default null
372 ,p_parent_message_id in number default null
373 ,p_person_id in number default null
374 ,p_contact_id in number default null
375 ,p_target_person_id in number default null
376 ,p_target_contact_id in number default null
377 ,p_forum_message_id out nocopy number
378 ,p_object_version_number out nocopy number
379 ) is
380 --
381 l_rec ota_fms_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 ota_fms_shd.convert_args
392 (null
393 ,p_forum_id
394 ,p_forum_thread_id
395 ,p_business_group_id
396 ,p_message_body
397 ,p_parent_message_id
398 ,p_person_id
399 ,p_contact_id
400 ,p_target_person_id
401 ,p_target_contact_id
402 ,p_message_scope
403 ,null
404 );
405 --
406 -- Having converted the arguments into the ota_fms_rec
407 -- plsql record structure we call the corresponding record business process.
408 --
409 ota_fms_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_forum_message_id := l_rec.forum_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 ota_fms_ins;