DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_PSE_INS

Source


1 Package Body per_pse_ins as
2 /* $Header: pepserhi.pkb 120.1 2008/07/22 09:16:58 rnemani noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  per_pse_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_pos_structure_element_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_pos_structure_element_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_pse_ins.g_pos_structure_element_id_i := p_pos_structure_element_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_pse_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   per_pse_shd.g_api_dml := true;  -- Set the api dml status
86   --
87   -- Insert the row into: per_pos_structure_elements
88   --
89   insert into per_pos_structure_elements
90       (pos_structure_element_id
91       ,business_group_id
92       ,pos_structure_version_id
93       ,subordinate_position_id
94       ,parent_position_id
95       ,request_id
96       ,program_application_id
97       ,program_id
98       ,program_update_date
99       ,object_version_number
100       )
101   Values
102     (p_rec.pos_structure_element_id
103     ,p_rec.business_group_id
104     ,p_rec.pos_structure_version_id
105     ,p_rec.subordinate_position_id
106     ,p_rec.parent_position_id
107     ,p_rec.request_id
108     ,p_rec.program_application_id
109     ,p_rec.program_id
110     ,p_rec.program_update_date
111     ,p_rec.object_version_number
112     );
113   --
114   per_pse_shd.g_api_dml := false;   -- Unset the api dml status
115   --
116   hr_utility.set_location(' Leaving:'||l_proc, 10);
117 Exception
118   When hr_api.check_integrity_violated Then
119     -- A check constraint has been violated
120     per_pse_shd.g_api_dml := false;   -- Unset the api dml status
121     per_pse_shd.constraint_error
122       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
123   When hr_api.parent_integrity_violated Then
124     -- Parent integrity has been violated
125     per_pse_shd.g_api_dml := false;   -- Unset the api dml status
126     per_pse_shd.constraint_error
127       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
128   When hr_api.unique_integrity_violated Then
129     -- Unique integrity has been violated
130     per_pse_shd.g_api_dml := false;   -- Unset the api dml status
131     per_pse_shd.constraint_error
132       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
133   When Others Then
134     per_pse_shd.g_api_dml := false;   -- Unset the api dml status
135     Raise;
136 End insert_dml;
137 --
138 -- ----------------------------------------------------------------------------
139 -- |------------------------------< pre_insert >------------------------------|
140 -- ----------------------------------------------------------------------------
141 -- {Start Of Comments}
142 --
143 -- Description:
144 --   This private procedure contains any processing which is required before
145 --   the insert dml. Presently, if the entity has a corresponding primary
146 --   key which is maintained by an associating sequence, the primary key for
147 --   the entity will be populated with the next sequence value in
148 --   preparation for the insert dml.
149 --
150 -- Prerequisites:
151 --   This is an internal procedure which is called from the ins procedure.
152 --
153 -- In Parameters:
154 --   A Pl/Sql record structre.
155 --
156 -- Post Success:
157 --   Processing continues.
158 --
159 -- Post Failure:
160 --   If an error has occurred, an error message and exception will be raised
161 --   but not handled.
162 --
163 -- Developer Implementation Notes:
164 --   Any pre-processing required before the insert dml is issued should be
165 --   coded within this procedure. As stated above, a good example is the
166 --   generation of a primary key number via a corresponding sequence.
167 --   It is important to note that any 3rd party maintenance should be reviewed
168 --   before placing in this procedure.
169 --
170 -- Access Status:
171 --   Internal Row Handler Use Only.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure pre_insert
176   (p_rec  in out nocopy per_pse_shd.g_rec_type
177   ) is
178 --
179   l_proc  varchar2(72) := g_package||'pre_insert';
180 --
181   Cursor C_Sel1 is select per_pos_structure_elements_s.nextval from sys.dual;
182 --
183 Begin
184   hr_utility.set_location('Entering:'||l_proc, 5);
185   --
186   --
187   -- Select the next sequence number
188   --
189   Open C_Sel1;
190   Fetch C_Sel1 Into p_rec.pos_structure_element_id;
191   Close C_Sel1;
192   --
193   hr_utility.set_location(' Leaving:'||l_proc, 10);
194 End pre_insert;
195 --
196 -- ----------------------------------------------------------------------------
197 -- |-----------------------------< post_insert >------------------------------|
198 -- ----------------------------------------------------------------------------
199 -- {Start Of Comments}
200 --
201 -- Description:
202 --   This private procedure contains any processing which is required after the
203 --   insert dml.
204 --
205 -- Prerequisites:
206 --   This is an internal procedure which is called from the ins procedure.
207 --
208 -- In Parameters:
209 --   A Pl/Sql record structre.
210 --
211 -- Post Success:
212 --   Processing continues.
213 --
214 -- Post Failure:
215 --   If an error has occurred, an error message and exception will be raised
216 --   but not handled.
217 --
218 -- Developer Implementation Notes:
219 --   Any post-processing required after the insert dml is issued should be
220 --   coded within this procedure. It is important to note that any 3rd party
221 --   maintenance should be reviewed before placing in this procedure.
222 --
223 -- Access Status:
224 --   Internal Row Handler Use Only.
225 --
226 -- {End Of Comments}
227 -- ----------------------------------------------------------------------------
228 Procedure post_insert
229   (p_rec                          in per_pse_shd.g_rec_type
230   ) is
231 --
232   l_proc  varchar2(72) := g_package||'post_insert';
233 --
234 Begin
235   hr_utility.set_location('Entering:'||l_proc, 5);
236   begin
237     --
238     per_pse_rki.after_insert
239       (p_pos_structure_element_id
240       => p_rec.pos_structure_element_id
241       ,p_business_group_id
242       => p_rec.business_group_id
243       ,p_pos_structure_version_id
244       => p_rec.pos_structure_version_id
245       ,p_subordinate_position_id
246       => p_rec.subordinate_position_id
247       ,p_parent_position_id
248       => p_rec.parent_position_id
249       ,p_request_id
250       => p_rec.request_id
251       ,p_program_application_id
252       => p_rec.program_application_id
253       ,p_program_id
254       => p_rec.program_id
255       ,p_program_update_date
256       => p_rec.program_update_date
257       ,p_object_version_number
258       => p_rec.object_version_number
259       );
260     --
261   exception
262     --
263     when hr_api.cannot_find_prog_unit then
264       --
265       hr_api.cannot_find_prog_unit_error
266         (p_module_name => 'PER_POS_STRUCTURE_ELEMENTS'
267         ,p_hook_type   => 'AI');
268       --
269   end;
270   --
271   hr_utility.set_location(' Leaving:'||l_proc, 10);
272 End post_insert;
273 --
274 -- ----------------------------------------------------------------------------
275 -- |---------------------------------< ins >----------------------------------|
276 -- ----------------------------------------------------------------------------
277 Procedure ins
278   (p_rec                          in out nocopy per_pse_shd.g_rec_type
279   ,p_effective_date               in date
280   ) is
281 --
282   l_proc  varchar2(72) := g_package||'ins';
283 --
284 Begin
285   hr_utility.set_location('Entering:'||l_proc, 5);
286   --
287   -- Call the supporting insert validate operations
288   --
289   per_pse_bus.insert_validate
290      (p_rec
291      ,p_effective_date
292      );
293   --
294   -- Call the supporting pre-insert operation
295   --
296   per_pse_ins.pre_insert(p_rec);
297   --
298   -- Insert the row
299   --
300   per_pse_ins.insert_dml(p_rec);
301   --
302   -- Call the supporting post-insert operation
303   --
304   per_pse_ins.post_insert
305      (p_rec
306      );
307   --
308   hr_utility.set_location('Leaving:'||l_proc, 20);
309 end ins;
310 --
311 -- ----------------------------------------------------------------------------
312 -- |---------------------------------< ins >----------------------------------|
313 -- ----------------------------------------------------------------------------
314 Procedure ins
315   (p_effective_date                 in     date
316   ,p_business_group_id              in     number
317   ,p_pos_structure_version_id       in     number
318   ,p_subordinate_position_id        in     number
319   ,p_parent_position_id             in     number
320   ,p_request_id                     in     number   default null
321   ,p_program_application_id         in     number   default null
322   ,p_program_id                     in     number   default null
323   ,p_program_update_date            in     date     default null
324   ,p_pos_structure_element_id          out nocopy number
325   ,p_object_version_number             out nocopy number
326   ) is
327 --
328   l_rec	  per_pse_shd.g_rec_type;
329   l_proc  varchar2(72) := g_package||'ins';
330 --
331 Begin
332   hr_utility.set_location('Entering:'||l_proc, 5);
333   --
334   -- Call conversion function to turn arguments into the
335   -- p_rec structure.
336   --
337   l_rec :=
338   per_pse_shd.convert_args
339     (null
340     ,p_business_group_id
341     ,p_pos_structure_version_id
342     ,p_subordinate_position_id
343     ,p_parent_position_id
344     ,p_request_id
345     ,p_program_application_id
346     ,p_program_id
347     ,p_program_update_date
348     ,null
349     );
350   --
351   -- Having converted the arguments into the per_pse_rec
352   -- plsql record structure we call the corresponding record business process.
353   --
354   per_pse_ins.ins
355      (l_rec
356      ,p_effective_date
357      );
358   --
359   -- As the primary key argument(s)
360   -- are specified as an OUT's we must set these values.
361   --
362   p_pos_structure_element_id := l_rec.pos_structure_element_id;
363   p_object_version_number := l_rec.object_version_number;
364   --
365   hr_utility.set_location(' Leaving:'||l_proc, 10);
366 End ins;
367 --
368 end per_pse_ins;