DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_OSE_INS

Source


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