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