DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BDT_INS

Source


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