DBA Data[Home] [Help]

PACKAGE BODY: APPS.GHR_CAD_INS

Source


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