DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_SOS_INS

Source


1 Package Body per_sos_ins as
2 /* $Header: pesosrhi.pkb 115.2 2003/08/08 00:05:41 vkonda noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_sos_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 g_solution_set_name_i  varchar2(120)   default null;
15 g_user_id_i            number   default null;
16 --
17 -- ----------------------------------------------------------------------------
18 -- |------------------------< set_base_key_value >----------------------------|
19 -- ----------------------------------------------------------------------------
20 procedure set_base_key_value
21   (p_solution_id  in  number
22   ,p_solution_set_name  in  varchar2
23   ,p_user_id  in  number) is
24 --
25   l_proc       varchar2(72) := g_package||'set_base_key_value';
26 --
27 Begin
28   hr_utility.set_location('Entering:'||l_proc, 10);
29   --
30   per_sos_ins.g_solution_id_i := p_solution_id;
31   per_sos_ins.g_solution_set_name_i := p_solution_set_name;
32   per_sos_ins.g_user_id_i := p_user_id;
33   --
34   hr_utility.set_location(' Leaving:'||l_proc, 20);
35 End set_base_key_value;
36 --
37 --
38 -- ----------------------------------------------------------------------------
39 -- |------------------------------< insert_dml >------------------------------|
40 -- ----------------------------------------------------------------------------
41 -- {Start Of Comments}
42 --
43 -- Description:
44 --   This procedure controls the actual dml insert logic. The processing of
45 --   this procedure are as follows:
46 --   1) Initialise the object_version_number to 1 if the object_version_number
47 --      is defined as an attribute for this entity.
48 --   2) To set and unset the g_api_dml status as required (as we are about to
49 --      perform dml).
50 --   3) To insert the row into the schema.
51 --   4) To trap any constraint violations that may have occurred.
52 --   5) To raise any other errors.
53 --
54 -- Prerequisites:
55 --   This is an internal private procedure which must be called from the ins
56 --   procedure and must have all mandatory attributes set (except the
57 --   object_version_number which is initialised within this procedure).
58 --
59 -- In Parameters:
60 --   A Pl/Sql record structre.
61 --
62 -- Post Success:
63 --   The specified row will be inserted into the schema.
64 --
65 -- Post Failure:
66 --   On the insert dml failure it is important to note that we always reset the
67 --   g_api_dml status to false.
68 --   If a check, unique or parent integrity constraint violation is raised the
69 --   constraint_error procedure will be called.
70 --   If any other error is reported, the error will be raised after the
71 --   g_api_dml status is reset.
72 --
73 -- Developer Implementation Notes:
74 --   None.
75 --
76 -- Access Status:
77 --   Internal Row Handler Use Only.
78 --
79 -- {End Of Comments}
80 -- ----------------------------------------------------------------------------
81 Procedure insert_dml
82   (p_rec in out nocopy per_sos_shd.g_rec_type
83   ) is
84 --
85   l_proc  varchar2(72) := g_package||'insert_dml';
86 --
87 Begin
88   hr_utility.set_location('Entering:'||l_proc, 5);
89   p_rec.object_version_number := 1;  -- Initialise the object version
90   --
91   --
92   --
93   -- Insert the row into: per_solutions_selected
94   --
95   insert into per_solutions_selected
96       (solution_id
97       ,solution_set_name
98       ,user_id
99       ,object_version_number
100       )
101   Values
102     (p_rec.solution_id
103     ,p_rec.solution_set_name
104     ,p_rec.user_id
105     ,p_rec.object_version_number
106     );
107   --
108   --
109   --
110   hr_utility.set_location(' Leaving:'||l_proc, 10);
111 Exception
112   When hr_api.check_integrity_violated Then
113     -- A check constraint has been violated
114     --
115     per_sos_shd.constraint_error
116       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117   When hr_api.parent_integrity_violated Then
118     -- Parent integrity has been violated
119     --
120     per_sos_shd.constraint_error
121       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122   When hr_api.unique_integrity_violated Then
123     -- Unique integrity has been violated
124     --
125     per_sos_shd.constraint_error
126       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127   When Others Then
128     --
129     Raise;
130 End insert_dml;
131 --
132 -- ----------------------------------------------------------------------------
133 -- |------------------------------< pre_insert >------------------------------|
134 -- ----------------------------------------------------------------------------
135 -- {Start Of Comments}
136 --
137 -- Description:
138 --   This private procedure contains any processing which is required before
139 --   the insert dml. Presently, if the entity has a corresponding primary
140 --   key which is maintained by an associating sequence, the primary key for
141 --   the entity will be populated with the next sequence value in
142 --   preparation for the insert dml.
143 --
144 -- Prerequisites:
145 --   This is an internal procedure which is called from the ins procedure.
146 --
147 -- In Parameters:
148 --   A Pl/Sql record structure.
149 --
150 -- Post Success:
151 --   Processing continues.
152 --
153 -- Post Failure:
154 --   If an error has occurred, an error message and exception will be raised
155 --   but not handled.
156 --
157 -- Developer Implementation Notes:
158 --   Any pre-processing required before the insert dml is issued should be
159 --   coded within this procedure. As stated above, a good example is the
160 --   generation of a primary key number via a corresponding sequence.
161 --   It is important to note that any 3rd party maintenance should be reviewed
162 --   before placing in this procedure.
163 --
164 -- Access Status:
165 --   Internal Row Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure pre_insert
170   (p_rec  in out nocopy per_sos_shd.g_rec_type
171   ) is
172 --
173   Cursor C_Sel2 is
174     Select null
175       from per_solutions_selected
176      where solution_id =
177              per_sos_ins.g_solution_id_i
178         and solution_set_name =
179              per_sos_ins.g_solution_set_name_i
180         and user_id =
181              per_sos_ins.g_user_id_i;
182 --
183   l_proc   varchar2(72) := g_package||'pre_insert';
184   l_exists varchar2(1);
185 --
186 Begin
187   hr_utility.set_location('Entering:'||l_proc, 5);
188   --
189   If (per_sos_ins.g_solution_id_i is not null or
190       per_sos_ins.g_solution_set_name_i is not null or
191       per_sos_ins.g_user_id_i is not null) Then
192     --
193     -- Verify registered primary key values not already in use
194     --
195     Open C_Sel2;
196     Fetch C_Sel2 into l_exists;
197     If C_Sel2%found Then
198        Close C_Sel2;
199        --
200        -- The primary key values are already in use.
201        --
202        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
203        fnd_message.set_token('TABLE_NAME','per_solutions_selected');
204        fnd_message.raise_error;
205     End If;
206     Close C_Sel2;
207     --
208     -- Use registered key values and clear globals
209     --
210     p_rec.solution_id :=
211       per_sos_ins.g_solution_id_i;
212     per_sos_ins.g_solution_id_i := null;
213     p_rec.solution_set_name :=
214       per_sos_ins.g_solution_set_name_i;
215     per_sos_ins.g_solution_set_name_i := null;
216     p_rec.user_id :=
217       per_sos_ins.g_user_id_i;
218     per_sos_ins.g_user_id_i := null;
219   Else
220     --
221     -- No registerd key values, so raise an error
222     --
223     hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
224     hr_utility.set_message_token('API_NAME', 'per_sos_ins');
225     hr_utility.set_message_token('ARGUMENT', 'base_key_value');
226     hr_utility.raise_error;
227   End If;
228   hr_utility.set_location(' Leaving:'||l_proc, 10);
229 End pre_insert;
230 --
231 -- ----------------------------------------------------------------------------
232 -- |-----------------------------< post_insert >------------------------------|
233 -- ----------------------------------------------------------------------------
234 -- {Start Of Comments}
235 --
236 -- Description:
237 --   This private procedure contains any processing which is required after
238 --   the insert dml.
239 --
240 -- Prerequisites:
241 --   This is an internal procedure which is called from the ins procedure.
242 --
243 -- In Parameters:
244 --   A Pl/Sql record structre.
245 --
246 -- Post Success:
247 --   Processing continues.
248 --
249 -- Post Failure:
250 --   If an error has occurred, an error message and exception will be raised
251 --   but not handled.
252 --
253 -- Developer Implementation Notes:
254 --   Any post-processing required after the insert dml is issued should be
255 --   coded within this procedure. It is important to note that any 3rd party
256 --   maintenance should be reviewed before placing in this procedure.
257 --
258 -- Access Status:
259 --   Internal Row Handler Use Only.
260 --
261 -- {End Of Comments}
262 -- ----------------------------------------------------------------------------
263 Procedure post_insert
264   (p_rec                          in per_sos_shd.g_rec_type
265   ) is
266 --
267   l_proc  varchar2(72) := g_package||'post_insert';
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   begin
272     --
273     per_sos_rki.after_insert
274       (p_solution_id
275       => p_rec.solution_id
276       ,p_solution_set_name
277       => p_rec.solution_set_name
278       ,p_user_id
279       => p_rec.user_id
280       ,p_object_version_number
281       => p_rec.object_version_number
282       );
283     --
284   exception
285     --
286     when hr_api.cannot_find_prog_unit then
287       --
288       hr_api.cannot_find_prog_unit_error
289         (p_module_name => 'PER_SOLUTIONS_SELECTED'
290         ,p_hook_type   => 'AI');
291       --
292   end;
293   --
294   hr_utility.set_location(' Leaving:'||l_proc, 10);
295 End post_insert;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |---------------------------------< ins >----------------------------------|
299 -- ----------------------------------------------------------------------------
300 Procedure ins
301   (p_rec                          in out nocopy per_sos_shd.g_rec_type
302   ) is
303 --
304   l_proc  varchar2(72) := g_package||'ins';
305 --
306 Begin
307   hr_utility.set_location('Entering:'||l_proc, 5);
308   --
309   -- Call the supporting insert validate operations
310   --
311   per_sos_bus.insert_validate
312      (p_rec
313      );
314   --
315   -- Call to raise any errors on multi-message list
316   hr_multi_message.end_validation_set;
317   --
318   -- Call the supporting pre-insert operation
319   --
320   per_sos_ins.pre_insert(p_rec);
321   --
322   -- Insert the row
323   --
324   per_sos_ins.insert_dml(p_rec);
325   --
326   -- Call the supporting post-insert operation
327   --
328   per_sos_ins.post_insert
329      (p_rec
330      );
331   --
332   -- Call to raise any errors on multi-message list
333   hr_multi_message.end_validation_set;
334   --
335   hr_utility.set_location('Leaving:'||l_proc, 20);
336 end ins;
337 --
338 -- ----------------------------------------------------------------------------
339 -- |---------------------------------< ins >----------------------------------|
340 -- ----------------------------------------------------------------------------
341 Procedure ins
342   (p_solution_id                       out nocopy number
343   ,p_solution_set_name                 out nocopy varchar2
344   ,p_user_id                           out nocopy number
345   ,p_object_version_number             out nocopy number
346   ) is
347 --
348   l_rec   per_sos_shd.g_rec_type;
349   l_proc  varchar2(72) := g_package||'ins';
350 --
351 Begin
352   hr_utility.set_location('Entering:'||l_proc, 5);
353   --
354   -- Call conversion function to turn arguments into the
355   -- p_rec structure.
356   --
357   l_rec :=
358   per_sos_shd.convert_args
359     (null
360     ,null
361     ,null
362     ,null
363     );
364   --
365   -- Having converted the arguments into the per_sos_rec
366   -- plsql record structure we call the corresponding record business process.
367   --
368   per_sos_ins.ins
369      (l_rec
370      );
371   --
372   -- As the primary key argument(s)
373   -- are specified as an OUT's we must set these values.
374   --
375   p_solution_id := l_rec.solution_id;
376   p_solution_set_name := l_rec.solution_set_name;
377   p_user_id := l_rec.user_id;
378   p_object_version_number := l_rec.object_version_number;
379   --
380   hr_utility.set_location(' Leaving:'||l_proc, 10);
381 End ins;
382 --
383 end per_sos_ins;