DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_GRA_INS

Source


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