DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SOL_INS

Source


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