DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_BCE_INS

Source


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