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