DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_WDT_INS

Source


1 Package Body pqh_wdt_ins as
2 /* $Header: pqwdtrhi.pkb 120.0.12000000.1 2007/01/17 00:29:46 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_wdt_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 insert the row into the schema.
21 --   3) To trap any constraint violations that may have occurred.
22 --   4) 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_wdt_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_worksheet_details
57   --
58   insert into pqh_worksheet_details
59   (	worksheet_detail_id,
60 	worksheet_id,
61 	organization_id,
62 	job_id,
63 	position_id,
64 	grade_id,
65 	position_transaction_id,
66 	budget_detail_id,
67 	parent_worksheet_detail_id,
68 	user_id,
69 	action_cd,
70 	budget_unit1_percent,
71 	budget_unit1_value,
72 	budget_unit2_percent,
73 	budget_unit2_value,
74 	budget_unit3_percent,
75 	budget_unit3_value,
76 	object_version_number,
77 	budget_unit1_value_type_cd,
78 	budget_unit2_value_type_cd,
79 	budget_unit3_value_type_cd,
80 	status,
81 	budget_unit1_available,
82 	budget_unit2_available,
83 	budget_unit3_available,
84 	old_unit1_value,
85 	old_unit2_value,
86 	old_unit3_value,
87 	defer_flag,
88 	propagation_method
89   )
90   Values
91   (	p_rec.worksheet_detail_id,
92 	p_rec.worksheet_id,
93 	p_rec.organization_id,
94 	p_rec.job_id,
95 	p_rec.position_id,
96 	p_rec.grade_id,
97 	p_rec.position_transaction_id,
98 	p_rec.budget_detail_id,
99 	p_rec.parent_worksheet_detail_id,
100 	p_rec.user_id,
101 	p_rec.action_cd,
102 	p_rec.budget_unit1_percent,
103 	p_rec.budget_unit1_value,
104 	p_rec.budget_unit2_percent,
105 	p_rec.budget_unit2_value,
106 	p_rec.budget_unit3_percent,
107 	p_rec.budget_unit3_value,
108 	p_rec.object_version_number,
109 	p_rec.budget_unit1_value_type_cd,
110 	p_rec.budget_unit2_value_type_cd,
111 	p_rec.budget_unit3_value_type_cd,
112 	p_rec.status,
113 	p_rec.budget_unit1_available,
114 	p_rec.budget_unit2_available,
115 	p_rec.budget_unit3_available,
116 	p_rec.old_unit1_value,
117 	p_rec.old_unit2_value,
118 	p_rec.old_unit3_value,
119 	p_rec.defer_flag,
120 	p_rec.propagation_method
121   );
122   --
123   --
124   hr_utility.set_location(' Leaving:'||l_proc, 10);
125 Exception
126   When hr_api.check_integrity_violated Then
127     -- A check constraint has been violated
128     pqh_wdt_shd.constraint_error
129       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
130   When hr_api.parent_integrity_violated Then
131     -- Parent integrity has been violated
132     pqh_wdt_shd.constraint_error
133       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
134   When hr_api.unique_integrity_violated Then
135     -- Unique integrity has been violated
136     pqh_wdt_shd.constraint_error
137       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
138   When Others Then
139     Raise;
140 End insert_dml;
141 --
142 -- ----------------------------------------------------------------------------
143 -- |------------------------------< pre_insert >------------------------------|
144 -- ----------------------------------------------------------------------------
145 -- {Start Of Comments}
146 --
147 -- Description:
148 --   This private procedure contains any processing which is required before
149 --   the insert dml. Presently, if the entity has a corresponding primary
150 --   key which is maintained by an associating sequence, the primary key for
151 --   the entity will be populated with the next sequence value in
152 --   preparation for the insert dml.
153 --
154 -- Prerequisites:
155 --   This is an internal procedure which is called from the ins procedure.
156 --
157 -- In Parameters:
158 --   A Pl/Sql record structre.
159 --
160 -- Post Success:
161 --   Processing continues.
162 --
163 -- Post Failure:
164 --   If an error has occurred, an error message and exception will be raised
165 --   but not handled.
166 --
167 -- Developer Implementation Notes:
168 --   Any pre-processing required before the insert dml is issued should be
169 --   coded within this procedure. As stated above, a good example is the
170 --   generation of a primary key number via a corresponding sequence.
171 --   It is important to note that any 3rd party maintenance should be reviewed
172 --   before placing in this procedure.
173 --
174 -- Access Status:
175 --   Internal Row Handler Use Only.
176 --
177 -- {End Of Comments}
178 -- ----------------------------------------------------------------------------
179 Procedure pre_insert(p_rec  in out nocopy pqh_wdt_shd.g_rec_type) is
180 --
181   l_proc  varchar2(72) := g_package||'pre_insert';
182 --
183   Cursor C_Sel1 is select pqh_worksheet_details_s.nextval from sys.dual;
184 --
185 Begin
186   hr_utility.set_location('Entering:'||l_proc, 5);
187   --
188   --
189   -- Select the next sequence number
190   --
191   Open C_Sel1;
192   Fetch C_Sel1 Into p_rec.worksheet_detail_id;
193   Close C_Sel1;
194   --
195   hr_utility.set_location(' Leaving:'||l_proc, 10);
196 End pre_insert;
197 --
198 -- ----------------------------------------------------------------------------
199 -- |-----------------------------< post_insert >------------------------------|
200 -- ----------------------------------------------------------------------------
201 -- {Start Of Comments}
202 --
203 -- Description:
204 --   This private procedure contains any processing which is required after the
205 --   insert dml.
206 --
207 -- Prerequisites:
208 --   This is an internal procedure which is called from the ins procedure.
209 --
210 -- In Parameters:
211 --   A Pl/Sql record structre.
212 --
213 -- Post Success:
214 --   Processing continues.
215 --
216 -- Post Failure:
217 --   If an error has occurred, an error message and exception will be raised
218 --   but not handled.
219 --
220 -- Developer Implementation Notes:
221 --   Any post-processing required after the insert dml is issued should be
222 --   coded within this procedure. It is important to note that any 3rd party
223 --   maintenance should be reviewed before placing in this procedure.
224 --
225 -- Access Status:
226 --   Internal Row Handler Use Only.
227 --
228 -- {End Of Comments}
229 -- ----------------------------------------------------------------------------
230 Procedure post_insert(
231 p_effective_date in date,p_rec in pqh_wdt_shd.g_rec_type) is
232 --
233   l_proc  varchar2(72) := g_package||'post_insert';
234 --
235 Begin
236   hr_utility.set_location('Entering:'||l_proc, 5);
237 --
238   --
239   -- Start of API User Hook for post_insert.
240   --
241   begin
242     --
243     pqh_wdt_rki.after_insert
244       (
245   p_worksheet_detail_id           =>p_rec.worksheet_detail_id
246  ,p_worksheet_id                  =>p_rec.worksheet_id
247  ,p_organization_id               =>p_rec.organization_id
248  ,p_job_id                        =>p_rec.job_id
249  ,p_position_id                   =>p_rec.position_id
250  ,p_grade_id                      =>p_rec.grade_id
251  ,p_position_transaction_id       =>p_rec.position_transaction_id
252  ,p_budget_detail_id              =>p_rec.budget_detail_id
253  ,p_parent_worksheet_detail_id    =>p_rec.parent_worksheet_detail_id
254  ,p_user_id                       =>p_rec.user_id
255  ,p_action_cd                     =>p_rec.action_cd
256  ,p_budget_unit1_percent          =>p_rec.budget_unit1_percent
257  ,p_budget_unit1_value            =>p_rec.budget_unit1_value
258  ,p_budget_unit2_percent          =>p_rec.budget_unit2_percent
259  ,p_budget_unit2_value            =>p_rec.budget_unit2_value
260  ,p_budget_unit3_percent          =>p_rec.budget_unit3_percent
261  ,p_budget_unit3_value            =>p_rec.budget_unit3_value
262  ,p_object_version_number         =>p_rec.object_version_number
263  ,p_budget_unit1_value_type_cd    =>p_rec.budget_unit1_value_type_cd
264  ,p_budget_unit2_value_type_cd    =>p_rec.budget_unit2_value_type_cd
265  ,p_budget_unit3_value_type_cd    =>p_rec.budget_unit3_value_type_cd
266  ,p_status                        =>p_rec.status
267  ,p_budget_unit1_available        =>p_rec.budget_unit1_available
268  ,p_budget_unit2_available        =>p_rec.budget_unit2_available
269  ,p_budget_unit3_available        =>p_rec.budget_unit3_available
270  ,p_old_unit1_value               =>p_rec.old_unit1_value
271  ,p_old_unit2_value               =>p_rec.old_unit2_value
272  ,p_old_unit3_value               =>p_rec.old_unit3_value
273  ,p_defer_flag                    =>p_rec.defer_flag
274  ,p_propagation_method            =>p_rec.propagation_method
275  ,p_effective_date                =>p_effective_date
276       );
277     --
278   exception
279     --
280     when hr_api.cannot_find_prog_unit then
281       --
282       hr_api.cannot_find_prog_unit_error
283         (p_module_name => 'pqh_worksheet_details'
284         ,p_hook_type   => 'AI');
285       --
286   end;
287   --
288   -- End of API User Hook for post_insert.
289   --
290   --
291   hr_utility.set_location(' Leaving:'||l_proc, 10);
292 End post_insert;
293 --
294 -- ----------------------------------------------------------------------------
295 -- |---------------------------------< ins >----------------------------------|
296 -- ----------------------------------------------------------------------------
297 Procedure ins
298   (
299   p_effective_date in date,
300   p_rec        in out nocopy pqh_wdt_shd.g_rec_type
301   ) is
302 --
303   l_proc  varchar2(72) := g_package||'ins';
304 --
305 Begin
306   hr_utility.set_location('Entering:'||l_proc, 5);
307   --
308   -- Call the supporting insert validate operations
309   --
310   pqh_wdt_bus.insert_validate(p_rec
311   ,p_effective_date);
312   --
313   -- Call the supporting pre-insert operation
314   --
315   pre_insert(p_rec);
316   --
317   -- Insert the row
318   --
319   insert_dml(p_rec);
320   --
321   -- Call the supporting post-insert operation
322   --
323   post_insert(
324 p_effective_date,p_rec);
325 end ins;
326 --
327 -- ----------------------------------------------------------------------------
328 -- |---------------------------------< ins >----------------------------------|
329 -- ----------------------------------------------------------------------------
330 Procedure ins
331   (
332   p_effective_date in date,
333   p_worksheet_detail_id          out nocopy number,
334   p_worksheet_id                 in number,
335   p_organization_id              in number           default null,
336   p_job_id                       in number           default null,
337   p_position_id                  in number           default null,
338   p_grade_id                     in number           default null,
339   p_position_transaction_id      in number           default null,
340   p_budget_detail_id             in number           default null,
341   p_parent_worksheet_detail_id   in number           default null,
342   p_user_id                      in number           default null,
343   p_action_cd                    in varchar2         default null,
344   p_budget_unit1_percent         in number           default null,
345   p_budget_unit1_value           in number           default null,
346   p_budget_unit2_percent         in number           default null,
347   p_budget_unit2_value           in number           default null,
348   p_budget_unit3_percent         in number           default null,
349   p_budget_unit3_value           in number           default null,
350   p_object_version_number        out nocopy number,
351   p_budget_unit1_value_type_cd   in varchar2         default null,
352   p_budget_unit2_value_type_cd   in varchar2         default null,
353   p_budget_unit3_value_type_cd   in varchar2         default null,
354   p_status                       in varchar2         default null,
355   p_budget_unit1_available       in number           default null,
356   p_budget_unit2_available       in number           default null,
357   p_budget_unit3_available       in number           default null,
358   p_old_unit1_value              in number           default null,
359   p_old_unit2_value              in number           default null,
360   p_old_unit3_value              in number           default null,
361   p_defer_flag                   in varchar2         default null,
362   p_propagation_method           in varchar2         default null
363   ) is
364 --
365   l_rec	  pqh_wdt_shd.g_rec_type;
366   l_proc  varchar2(72) := g_package||'ins';
367 --
368 Begin
369   hr_utility.set_location('Entering:'||l_proc, 5);
370   --
371   -- Call conversion function to turn arguments into the
372   -- p_rec structure.
373   --
374   l_rec :=
375   pqh_wdt_shd.convert_args
376   (
377   null,
378   p_worksheet_id,
379   p_organization_id,
380   p_job_id,
381   p_position_id,
382   p_grade_id,
383   p_position_transaction_id,
384   p_budget_detail_id,
385   p_parent_worksheet_detail_id,
386   p_user_id,
387   p_action_cd,
388   p_budget_unit1_percent,
389   p_budget_unit1_value,
390   p_budget_unit2_percent,
391   p_budget_unit2_value,
392   p_budget_unit3_percent,
393   p_budget_unit3_value,
394   null,
395   p_budget_unit1_value_type_cd,
396   p_budget_unit2_value_type_cd,
397   p_budget_unit3_value_type_cd,
398   p_status,
399   p_budget_unit1_available,
400   p_budget_unit2_available,
401   p_budget_unit3_available,
402   p_old_unit1_value,
403   p_old_unit2_value,
404   p_old_unit3_value,
405   p_defer_flag,
406   p_propagation_method
407   );
408   --
409   -- Having converted the arguments into the pqh_wdt_rec
410   -- plsql record structure we call the corresponding record business process.
411   --
412   ins(
413     p_effective_date,l_rec);
414   --
415   -- As the primary key argument(s)
416   -- are specified as an OUT's we must set these values.
417   --
418   p_worksheet_detail_id := l_rec.worksheet_detail_id;
419   p_object_version_number := l_rec.object_version_number;
420   --
421   hr_utility.set_location(' Leaving:'||l_proc, 10);
422 End ins;
423 --
424 end pqh_wdt_ins;