1 Package Body pqh_bpr_ins as
2 /* $Header: pqbprrhi.pkb 115.8 2002/12/05 19:29:59 rpasapul ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pqh_bpr_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_bpr_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_periods
57 --
58 insert into pqh_budget_periods
59 ( budget_period_id,
60 budget_detail_id,
61 start_time_period_id,
62 end_time_period_id,
63 budget_unit1_percent,
64 budget_unit2_percent,
65 budget_unit3_percent,
66 budget_unit1_value,
67 budget_unit2_value,
68 budget_unit3_value,
69 budget_unit1_value_type_cd,
70 budget_unit2_value_type_cd,
71 budget_unit3_value_type_cd,
72 budget_unit1_available,
73 budget_unit2_available,
74 budget_unit3_available,
75 object_version_number
76 )
77 Values
78 ( p_rec.budget_period_id,
79 p_rec.budget_detail_id,
80 p_rec.start_time_period_id,
81 p_rec.end_time_period_id,
82 p_rec.budget_unit1_percent,
83 p_rec.budget_unit2_percent,
84 p_rec.budget_unit3_percent,
85 p_rec.budget_unit1_value,
86 p_rec.budget_unit2_value,
87 p_rec.budget_unit3_value,
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.budget_unit1_available,
92 p_rec.budget_unit2_available,
93 p_rec.budget_unit3_available,
94 p_rec.object_version_number
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_bpr_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_bpr_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_bpr_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_bpr_shd.g_rec_type) is
154 --
155 l_proc varchar2(72) := g_package||'pre_insert';
156 --
157 Cursor C_Sel1 is select pqh_budget_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.budget_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(p_rec in pqh_bpr_shd.g_rec_type) is
205 --
206 l_proc varchar2(72) := g_package||'post_insert';
207 --
208 Begin
209 hr_utility.set_location('Entering:'||l_proc, 5);
210 --
211 --
212 -- Start of API User Hook for post_insert.
213 --
214 begin
215 --
216 pqh_bpr_rki.after_insert
217 (
218 p_budget_period_id =>p_rec.budget_period_id
219 ,p_budget_detail_id =>p_rec.budget_detail_id
220 ,p_start_time_period_id =>p_rec.start_time_period_id
221 ,p_end_time_period_id =>p_rec.end_time_period_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_budget_unit1_value_type_cd =>p_rec.budget_unit1_value_type_cd
229 ,p_budget_unit2_value_type_cd =>p_rec.budget_unit2_value_type_cd
230 ,p_budget_unit3_value_type_cd =>p_rec.budget_unit3_value_type_cd
231 ,p_budget_unit1_available =>p_rec.budget_unit1_available
232 ,p_budget_unit2_available =>p_rec.budget_unit2_available
233 ,p_budget_unit3_available =>p_rec.budget_unit3_available
234 ,p_object_version_number =>p_rec.object_version_number
235 );
236 --
237 exception
238 --
239 when hr_api.cannot_find_prog_unit then
240 --
241 hr_api.cannot_find_prog_unit_error
242 (p_module_name => 'pqh_budget_periods'
243 ,p_hook_type => 'AI');
244 --
245 end;
246 --
247 -- End of API User Hook for post_insert.
248 --
249 --
250 hr_utility.set_location(' Leaving:'||l_proc, 10);
251 End post_insert;
252 --
253 -- ----------------------------------------------------------------------------
254 -- |---------------------------------< ins >----------------------------------|
255 -- ----------------------------------------------------------------------------
256 Procedure ins
257 (
258 p_rec in out nocopy pqh_bpr_shd.g_rec_type
259 ) is
260 --
261 l_proc varchar2(72) := g_package||'ins';
262 --
263 Begin
264 hr_utility.set_location('Entering:'||l_proc, 5);
265 --
266 -- Call the supporting insert validate operations
267 --
268 pqh_bpr_bus.insert_validate(p_rec);
269 --
270 -- Call the supporting pre-insert operation
271 --
272 pre_insert(p_rec);
273 --
274 -- Insert the row
275 --
276 insert_dml(p_rec);
277 --
278 -- Call the supporting post-insert operation
279 --
280 post_insert(p_rec);
281 end ins;
282 --
283 -- ----------------------------------------------------------------------------
284 -- |---------------------------------< ins >----------------------------------|
285 -- ----------------------------------------------------------------------------
286 Procedure ins
287 (
288 p_budget_period_id out nocopy number,
289 p_budget_detail_id in number,
290 p_start_time_period_id in number,
291 p_end_time_period_id in number,
292 p_budget_unit1_percent in number default null,
293 p_budget_unit2_percent in number default null,
294 p_budget_unit3_percent in number default null,
295 p_budget_unit1_value in number default null,
296 p_budget_unit2_value in number default null,
297 p_budget_unit3_value in number default null,
298 p_budget_unit1_value_type_cd in varchar2 default null,
299 p_budget_unit2_value_type_cd in varchar2 default null,
300 p_budget_unit3_value_type_cd in varchar2 default null,
301 p_budget_unit1_available in number default null,
302 p_budget_unit2_available in number default null,
303 p_budget_unit3_available in number default null,
304 p_object_version_number out nocopy number
305 ) is
306 --
307 l_rec pqh_bpr_shd.g_rec_type;
308 l_proc varchar2(72) := g_package||'ins';
309 --
310 Begin
311 hr_utility.set_location('Entering:'||l_proc, 5);
312 --
313 -- Call conversion function to turn arguments into the
314 -- p_rec structure.
315 --
316 l_rec :=
317 pqh_bpr_shd.convert_args
318 (
319 null,
320 p_budget_detail_id,
321 p_start_time_period_id,
322 p_end_time_period_id,
323 p_budget_unit1_percent,
324 p_budget_unit2_percent,
325 p_budget_unit3_percent,
326 p_budget_unit1_value,
327 p_budget_unit2_value,
328 p_budget_unit3_value,
329 p_budget_unit1_value_type_cd,
330 p_budget_unit2_value_type_cd,
331 p_budget_unit3_value_type_cd,
332 p_budget_unit1_available,
333 p_budget_unit2_available,
334 p_budget_unit3_available,
335 null
336 );
337 --
338 -- Having converted the arguments into the pqh_bpr_rec
339 -- plsql record structure we call the corresponding record business process.
340 --
341 ins(l_rec);
342 --
343 -- As the primary key argument(s)
344 -- are specified as an OUT's we must set these values.
345 --
346 p_budget_period_id := l_rec.budget_period_id;
347 p_object_version_number := l_rec.object_version_number;
348 --
349 hr_utility.set_location(' Leaving:'||l_proc, 10);
350 End ins;
351 --
352 end pqh_bpr_ins;