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