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