DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_WPR_INS

Source


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