1 Package Body ben_xcv_ins as
2 /* $Header: bexcvrhi.pkb 120.3 2006/04/11 11:18:40 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
10 --
7 --
8 g_package varchar2(33) := ' ben_xcv_ins.'; -- Global package name
9
11 -- ----------------------------------------------------------------------------
12 -- |-----------------------< create_app_ownerships >--------------------------|
13 -- ----------------------------------------------------------------------------
14 --
15 -- Description:
16 -- This procedure inserts a row into the HR_APPLICATION_OWNERSHIPS table
17 -- when the row handler is called in the appropriate mode.
18 --
19 -- ----------------------------------------------------------------------------
20 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
21 ,p_pk_value IN varchar2) IS
22 --
23 CURSOR csr_definition (p_session_id NUMBER) IS
24 SELECT product_short_name
25 FROM hr_owner_definitions
26 WHERE session_id = p_session_id;
27 --
28 l_session_id NUMBER;
29 --
30 BEGIN
31 --
32 IF (hr_startup_data_api_support.return_startup_mode IN
33 ('STARTUP','GENERIC')) THEN
34 --
35 l_session_id := nvl(hr_startup_data_api_support.g_startup_session_id
36 ,hr_startup_data_api_support.g_session_id);
37 --
38 FOR c1 IN csr_definition(l_session_id) LOOP
39 --
40 INSERT INTO hr_application_ownerships
41 (key_name
42 ,key_value
43 ,product_name
44 )
45 VALUES
46 (p_pk_column
47 ,fnd_number.number_to_canonical(p_pk_value)
48 ,c1.product_short_name
49 );
50 END LOOP;
51 END IF;
52 END create_app_ownerships;
53 --
54 -- ----------------------------------------------------------------------------
55 -- |-----------------------< create_app_ownerships >--------------------------|
56 -- ----------------------------------------------------------------------------
57 PROCEDURE create_app_ownerships(p_pk_column IN varchar2
58 ,p_pk_value IN number) IS
59 --
60 BEGIN
61 create_app_ownerships(p_pk_column, to_char(p_pk_value));
62 END create_app_ownerships;
63
64 --
65 -- ----------------------------------------------------------------------------
66 -- |------------------------------< insert_dml >------------------------------|
67 -- ----------------------------------------------------------------------------
68 -- {Start Of Comments}
69 --
70 -- Description:
71 -- This procedure controls the actual dml insert logic. The processing of
72 -- this procedure are as follows:
73 -- 1) Initialise the object_version_number to 1 if the object_version_number
74 -- is defined as an attribute for this entity.
75 -- 2) To set and unset the g_api_dml status as required (as we are about to
76 -- perform dml).
77 -- 3) To insert the row into the schema.
78 -- 4) To trap any constraint violations that may have occurred.
79 -- 5) To raise any other errors.
80 --
81 -- Prerequisites:
82 -- This is an internal private procedure which must be called from the ins
83 -- procedure and must have all mandatory attributes set (except the
84 -- object_version_number which is initialised within this procedure).
85 --
86 -- In Parameters:
87 -- A Pl/Sql record structre.
88 --
89 -- Post Success:
90 -- The specified row will be inserted into the schema.
91 --
92 -- Post Failure:
93 -- On the insert dml failure it is important to note that we always reset the
94 -- g_api_dml status to false.
95 -- If a check, unique or parent integrity constraint violation is raised the
96 -- constraint_error procedure will be called.
97 -- If any other error is reported, the error will be raised after the
98 -- g_api_dml status is reset.
99 --
100 -- Developer Implementation Notes:
101 -- None.
102 --
103 -- Access Status:
104 -- Internal Row Handler Use Only.
105 --
106 -- {End Of Comments}
107 -- ----------------------------------------------------------------------------
108 Procedure insert_dml(p_rec in out nocopy ben_xcv_shd.g_rec_type) is
109 --
110 l_proc varchar2(72) := g_package||'insert_dml';
111 --
112 Begin
113 hr_utility.set_location('Entering:'||l_proc, 5);
114 p_rec.object_version_number := 1; -- Initialise the object version
115 --
116 ben_xcv_shd.g_api_dml := true; -- Set the api dml status
117 --
118 -- Insert the row into: ben_ext_crit_val
119 --
120 insert into ben_ext_crit_val
121 ( ext_crit_val_id,
122 val_1,
123 val_2,
124 ext_crit_typ_id,
125 business_group_id,
126 ext_crit_bg_id,
127 legislation_code,
128 last_update_date,
129 creation_date,
130 last_updated_by,
131 last_update_login,
132 created_by,
133 object_version_number
134 )
135 Values
136 ( p_rec.ext_crit_val_id,
137 p_rec.val_1,
138 p_rec.val_2,
139 p_rec.ext_crit_typ_id,
140 p_rec.business_group_id,
141 p_rec.ext_crit_bg_id,
142 p_rec.legislation_code,
143 p_rec.last_update_date,
144 p_rec.creation_date,
145 p_rec.last_updated_by,
146 p_rec.last_update_login,
147 p_rec.created_by,
148 p_rec.object_version_number
149 );
150 --
151 ben_xcv_shd.g_api_dml := false; -- Unset the api dml status
152 --
153 hr_utility.set_location(' Leaving:'||l_proc, 10);
154 Exception
155 When hr_api.check_integrity_violated Then
156 -- A check constraint has been violated
157 ben_xcv_shd.g_api_dml := false; -- Unset the api dml status
158 ben_xcv_shd.constraint_error
159 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
160 When hr_api.parent_integrity_violated Then
161 -- Parent integrity has been violated
162 ben_xcv_shd.g_api_dml := false; -- Unset the api dml status
163 ben_xcv_shd.constraint_error
164 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
165 When hr_api.unique_integrity_violated Then
166 -- Unique integrity has been violated
167 ben_xcv_shd.g_api_dml := false; -- Unset the api dml status
168 ben_xcv_shd.constraint_error
169 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
170 When Others Then
171 ben_xcv_shd.g_api_dml := false; -- Unset the api dml status
172 Raise;
173 End insert_dml;
174 --
175 -- ----------------------------------------------------------------------------
176 -- |------------------------------< pre_insert >------------------------------|
177 -- ----------------------------------------------------------------------------
178 -- {Start Of Comments}
179 --
180 -- Description:
181 -- This private procedure contains any processing which is required before
182 -- the insert dml. Presently, if the entity has a corresponding primary
183 -- key which is maintained by an associating sequence, the primary key for
184 -- the entity will be populated with the next sequence value in
185 -- preparation for the insert dml.
186 --
187 -- Prerequisites:
188 -- This is an internal procedure which is called from the ins procedure.
189 --
190 -- In Parameters:
191 -- A Pl/Sql record structre.
192 --
193 -- Post Success:
194 -- Processing continues.
195 --
196 -- Post Failure:
197 -- If an error has occurred, an error message and exception will be raised
198 -- but not handled.
199 --
200 -- Developer Implementation Notes:
201 -- Any pre-processing required before the insert dml is issued should be
202 -- coded within this procedure. As stated above, a good example is the
203 -- generation of a primary key number via a corresponding sequence.
204 -- It is important to note that any 3rd party maintenance should be reviewed
205 -- before placing in this procedure.
206 --
207 -- Access Status:
208 -- Internal Row Handler Use Only.
209 --
210 -- {End Of Comments}
211 -- ----------------------------------------------------------------------------
212 Procedure pre_insert(p_rec in out nocopy ben_xcv_shd.g_rec_type) is
213 --
214 l_proc varchar2(72) := g_package||'pre_insert';
215 --
216 cursor c1 is
217 select ben_ext_crit_val_s.nextval
218 from sys.dual;
219 --
220 Begin
221 hr_utility.set_location('Entering:'||l_proc, 5);
222 --
223 open c1;
224 fetch c1 into p_rec.ext_crit_val_id;
225 close c1;
226 --
227 hr_utility.set_location(' Leaving:'||l_proc, 10);
228 End pre_insert;
229 --
230 -- ----------------------------------------------------------------------------
231 -- |-----------------------------< post_insert >------------------------------|
232 -- ----------------------------------------------------------------------------
233 -- {Start Of Comments}
234 --
235 -- Description:
236 -- This private procedure contains any processing which is required after the
237 -- insert dml.
238 --
239 -- Prerequisites:
240 -- This is an internal procedure which is called from the ins procedure.
241 --
242 -- In Parameters:
243 -- A Pl/Sql record structre.
244 --
245 -- Post Success:
246 -- Processing continues.
247 --
248 -- Post Failure:
249 -- If an error has occurred, an error message and exception will be raised
250 -- but not handled.
251 --
252 -- Developer Implementation Notes:
253 -- Any post-processing required after the insert dml is issued should be
254 -- coded within this procedure. It is important to note that any 3rd party
255 -- maintenance should be reviewed before placing in this procedure.
256 --
257 -- Access Status:
258 -- Internal Row Handler Use Only.
259 --
260 -- {End Of Comments}
261 -- ----------------------------------------------------------------------------
262 Procedure post_insert(p_rec in ben_xcv_shd.g_rec_type) is
263 --
264 l_proc varchar2(72) := g_package||'post_insert';
265 --
266 Begin
267 hr_utility.set_location('Entering:'||l_proc, 5);
268 --
269 --
270 -- insert ownerships if applicable
271 --
272 create_app_ownerships('EXT_CRIT_VAL_ID', p_rec.ext_crit_val_id);
273 --
274 -- Start of API User Hook for post_insert.
275 --
276 begin
277 --
278 ben_xcv_rki.after_insert
279 (
280 p_ext_crit_val_id =>p_rec.ext_crit_val_id
281 ,p_val_1 =>p_rec.val_1
282 ,p_val_2 =>p_rec.val_2
283 ,p_ext_crit_typ_id =>p_rec.ext_crit_typ_id
284 ,p_business_group_id =>p_rec.business_group_id
285 ,p_ext_crit_bg_id =>p_rec.ext_crit_bg_id
286 ,p_legislation_code =>p_rec.legislation_code
287 ,p_object_version_number =>p_rec.object_version_number
288 );
289 --
290 exception
291 --
292 when hr_api.cannot_find_prog_unit then
293 --
294 hr_api.cannot_find_prog_unit_error
295 (p_module_name => 'ben_ext_crit_val'
296 ,p_hook_type => 'AI');
297 --
298 end;
299 --
300 -- End of API User Hook for post_insert.
301 --
302 --
303 hr_utility.set_location(' Leaving:'||l_proc, 10);
304 End post_insert;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< ins >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure ins
310 (
311 p_effective_date in date,
312 p_rec in out nocopy ben_xcv_shd.g_rec_type
313 ) is
314 --
315 l_proc varchar2(72) := g_package||'ins';
316 --
317 Begin
318 hr_utility.set_location('Entering:'||l_proc, 5);
319 --
320 -- Call the supporting insert validate operations
321 --
322 ben_xcv_bus.insert_validate(p_rec
323 ,p_effective_date);
324 --
325 -- Call the supporting pre-insert operation
326 --
327 pre_insert(p_rec);
328 --
329 -- Insert the row
330 --
331 insert_dml(p_rec);
332 --
333 -- Call the supporting post-insert operation
334 --
335 post_insert(p_rec);
336 end ins;
337 --
338 -- ----------------------------------------------------------------------------
339 -- |---------------------------------< ins >----------------------------------|
340 -- ----------------------------------------------------------------------------
341 Procedure ins
342 (
343 p_effective_date in date,
344 p_ext_crit_val_id out nocopy number,
345 p_val_1 in varchar2,
346 p_val_2 in varchar2 default null,
347 p_ext_crit_typ_id in number,
348 p_business_group_id in number,
349 p_ext_crit_bg_id in number default null,
350 p_legislation_code in varchar2 default null,
351 p_last_update_date in date default null,
352 p_creation_date in date default null,
353 p_last_updated_by in number default null,
354 p_last_update_login in number default null,
355 p_created_by in number default null,
356 p_object_version_number out nocopy number
357 ) is
358 --
359 l_rec ben_xcv_shd.g_rec_type;
360 l_proc varchar2(72) := g_package||'ins';
361 --
362 Begin
363 hr_utility.set_location('Entering:'||l_proc, 5);
364 --
365 -- Call conversion function to turn arguments into the
366 -- p_rec structure.
367 --
368 l_rec :=
369 ben_xcv_shd.convert_args
370 (
371 null,
372 p_val_1,
373 p_val_2,
374 p_ext_crit_typ_id,
375 p_business_group_id,
376 p_ext_crit_bg_id,
377 p_legislation_code,
378 p_last_update_date,
379 p_creation_date ,
380 p_last_updated_by ,
381 p_last_update_login,
382 p_created_by ,
383 null
384 );
385 --
386 -- Having converted the arguments into the ben_xcv_rec
387 -- plsql record structure we call the corresponding record business process.
388 --
389 ins(p_effective_date,l_rec);
390 --
391 -- As the primary key argument(s)
392 -- are specified as an OUT's we must set these values.
393 --
394 p_ext_crit_val_id := l_rec.ext_crit_val_id;
395 p_object_version_number := l_rec.object_version_number;
396 --
397 hr_utility.set_location(' Leaving:'||l_proc, 10);
398 End ins;
399 --
400 end ben_xcv_ins;