DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_JGR_INS

Source


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