1 Package Body ben_xwc_ins as
2 /* $Header: bexwcrhi.pkb 120.3 2006/04/27 11:31:07 tjesumic noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_xwc_ins.'; -- Global package name
9
10 --
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_xwc_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_xwc_shd.g_api_dml := true; -- Set the api dml status
117 --
118 -- Insert the row into: ben_ext_where_clause
119 --
120 insert into ben_ext_where_clause
121 ( ext_where_clause_id,
122 seq_num,
123 oper_cd,
124 val,
125 and_or_cd,
126 ext_data_elmt_id,
127 cond_ext_data_elmt_id,
128 ext_rcd_in_file_id,
129 ext_data_elmt_in_rcd_id,
130 business_group_id,
131 legislation_code,
132 last_update_date,
133 creation_date,
134 last_updated_by,
135 last_update_login,
136 created_by,
137 object_version_number,
138 cond_ext_data_elmt_in_rcd_id
139 )
140 Values
141 ( p_rec.ext_where_clause_id,
142 p_rec.seq_num,
143 p_rec.oper_cd,
144 p_rec.val,
145 p_rec.and_or_cd,
146 p_rec.ext_data_elmt_id,
147 p_rec.cond_ext_data_elmt_id,
148 p_rec.ext_rcd_in_file_id,
149 p_rec.ext_data_elmt_in_rcd_id,
150 p_rec.business_group_id,
151 p_rec.legislation_code,
152 p_rec.last_update_date,
153 p_rec.creation_date,
154 p_rec.last_updated_by,
155 p_rec.last_update_login,
156 p_rec.created_by,
157 p_rec.object_version_number,
158 p_rec.cond_ext_data_elmt_in_rcd_id
159 );
160 --
161 ben_xwc_shd.g_api_dml := false; -- Unset the api dml status
162 --
163 hr_utility.set_location(' Leaving:'||l_proc, 10);
164 Exception
165 When hr_api.check_integrity_violated Then
166 -- A check constraint has been violated
167 ben_xwc_shd.g_api_dml := false; -- Unset the api dml status
168 ben_xwc_shd.constraint_error
169 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
170 When hr_api.parent_integrity_violated Then
171 -- Parent integrity has been violated
172 ben_xwc_shd.g_api_dml := false; -- Unset the api dml status
173 ben_xwc_shd.constraint_error
174 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
175 When hr_api.unique_integrity_violated Then
176 -- Unique integrity has been violated
177 ben_xwc_shd.g_api_dml := false; -- Unset the api dml status
178 ben_xwc_shd.constraint_error
179 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
180 When Others Then
181 ben_xwc_shd.g_api_dml := false; -- Unset the api dml status
182 Raise;
183 End insert_dml;
184 --
185 -- ----------------------------------------------------------------------------
186 -- |------------------------------< pre_insert >------------------------------|
187 -- ----------------------------------------------------------------------------
188 -- {Start Of Comments}
189 --
190 -- Description:
191 -- This private procedure contains any processing which is required before
192 -- the insert dml. Presently, if the entity has a corresponding primary
193 -- key which is maintained by an associating sequence, the primary key for
194 -- the entity will be populated with the next sequence value in
195 -- preparation for the insert dml.
196 --
197 -- Prerequisites:
198 -- This is an internal procedure which is called from the ins procedure.
199 --
200 -- In Parameters:
201 -- A Pl/Sql record structre.
202 --
203 -- Post Success:
204 -- Processing continues.
205 --
206 -- Post Failure:
207 -- If an error has occurred, an error message and exception will be raised
208 -- but not handled.
209 --
210 -- Developer Implementation Notes:
211 -- Any pre-processing required before the insert dml is issued should be
212 -- coded within this procedure. As stated above, a good example is the
213 -- generation of a primary key number via a corresponding sequence.
214 -- It is important to note that any 3rd party maintenance should be reviewed
215 -- before placing in this procedure.
216 --
217 -- Access Status:
218 -- Internal Row Handler Use Only.
219 --
220 -- {End Of Comments}
221 -- ----------------------------------------------------------------------------
222 Procedure pre_insert(p_rec in out nocopy ben_xwc_shd.g_rec_type) is
223 --
224 l_proc varchar2(72) := g_package||'pre_insert';
225 --
226 Cursor C_Sel1 is select ben_ext_where_clause_s.nextval from sys.dual;
227 --
228 Begin
229 hr_utility.set_location('Entering:'||l_proc, 5);
230 --
231 --
232 -- Select the next sequence number
233 --
234 Open C_Sel1;
235 Fetch C_Sel1 Into p_rec.ext_where_clause_id;
236 Close C_Sel1;
237 --
238 hr_utility.set_location(' Leaving:'||l_proc, 10);
239 End pre_insert;
240 --
241 -- ----------------------------------------------------------------------------
242 -- |-----------------------------< post_insert >------------------------------|
243 -- ----------------------------------------------------------------------------
244 -- {Start Of Comments}
245 --
246 -- Description:
247 -- This private procedure contains any processing which is required after the
248 -- insert dml.
249 --
250 -- Prerequisites:
251 -- This is an internal procedure which is called from the ins procedure.
252 --
253 -- In Parameters:
254 -- A Pl/Sql record structre.
255 --
256 -- Post Success:
257 -- Processing continues.
258 --
259 -- Post Failure:
260 -- If an error has occurred, an error message and exception will be raised
261 -- but not handled.
262 --
263 -- Developer Implementation Notes:
264 -- Any post-processing required after the insert dml is issued should be
265 -- coded within this procedure. It is important to note that any 3rd party
266 -- maintenance should be reviewed before placing in this procedure.
267 --
268 -- Access Status:
269 -- Internal Row Handler Use Only.
270 --
271 -- {End Of Comments}
272 -- ----------------------------------------------------------------------------
273 Procedure post_insert(
274 p_effective_date in date,p_rec in ben_xwc_shd.g_rec_type) is
275 --
276 l_proc varchar2(72) := g_package||'post_insert';
277 --
278 Begin
279 hr_utility.set_location('Entering:'||l_proc, 5);
280 --
281 --
282 -- insert ownerships if applicable
283 --
284 create_app_ownerships('EXT_WHERE_CLAUSE_ID', p_rec.ext_where_clause_id);
285 --
286 -- Start of API User Hook for post_insert.
287 --
288 begin
289 --
290 ben_xwc_rki.after_insert
291 (
292 p_ext_where_clause_id =>p_rec.ext_where_clause_id
293 ,p_seq_num =>p_rec.seq_num
294 ,p_oper_cd =>p_rec.oper_cd
295 ,p_val =>p_rec.val
296 ,p_and_or_cd =>p_rec.and_or_cd
297 ,p_ext_data_elmt_id =>p_rec.ext_data_elmt_id
298 ,p_cond_ext_data_elmt_id =>p_rec.cond_ext_data_elmt_id
299 ,p_ext_rcd_in_file_id =>p_rec.ext_rcd_in_file_id
300 ,p_ext_data_elmt_in_rcd_id =>p_rec.ext_data_elmt_in_rcd_id
301 ,p_business_group_id =>p_rec.business_group_id
302 ,p_legislation_code =>p_rec.legislation_code
303 ,p_object_version_number =>p_rec.object_version_number
304 ,p_cond_ext_data_elmt_in_rcd_id =>p_rec.cond_ext_data_elmt_in_rcd_id
305 ,p_effective_date =>p_effective_date
306 );
307 --
308 exception
309 --
310 when hr_api.cannot_find_prog_unit then
311 --
312 hr_api.cannot_find_prog_unit_error
313 (p_module_name => 'ben_ext_where_clause'
314 ,p_hook_type => 'AI');
315 --
316 end;
317 --
318 -- End of API User Hook for post_insert.
319 --
320 --
321 hr_utility.set_location(' Leaving:'||l_proc, 10);
322 End post_insert;
323 --
324 -- ----------------------------------------------------------------------------
325 -- |---------------------------------< ins >----------------------------------|
326 -- ----------------------------------------------------------------------------
327 Procedure ins
328 (
329 p_effective_date in date,
330 p_rec in out nocopy ben_xwc_shd.g_rec_type
331 ) is
332 --
333 l_proc varchar2(72) := g_package||'ins';
334 --
335 Begin
336 hr_utility.set_location('Entering:'||l_proc, 5);
337 --
338 -- Call the supporting insert validate operations
339 --
340 ben_xwc_bus.insert_validate(p_rec
341 ,p_effective_date);
342 --
343 -- Call the supporting pre-insert operation
344 --
345 pre_insert(p_rec);
346 --
347 -- Insert the row
348 --
349 insert_dml(p_rec);
350 --
351 -- Call the supporting post-insert operation
352 --
353 post_insert(
354 p_effective_date,p_rec);
355 end ins;
356 --
357 -- ----------------------------------------------------------------------------
358 -- |---------------------------------< ins >----------------------------------|
359 -- ----------------------------------------------------------------------------
360 Procedure ins
361 (
362 p_effective_date in date,
363 p_ext_where_clause_id out nocopy number,
364 p_seq_num in number default null,
365 p_oper_cd in varchar2 default null,
366 p_val in varchar2 default null,
367 p_and_or_cd in varchar2 default null,
368 p_ext_data_elmt_id in number,
369 p_cond_ext_data_elmt_id in number default null,
370 p_ext_rcd_in_file_id in number default null,
371 p_ext_data_elmt_in_rcd_id in number default null,
372 p_business_group_id in number,
373 p_legislation_code in varchar2 default null,
374 p_last_update_date in date default null,
375 p_creation_date in date default null,
376 p_last_updated_by in number default null,
377 p_last_update_login in number default null,
378 p_created_by in number default null,
379 p_object_version_number out nocopy number,
380 p_cond_ext_data_elmt_in_rcd_id in number default null
381 ) is
382 --
383 l_rec ben_xwc_shd.g_rec_type;
384 l_proc varchar2(72) := g_package||'ins';
385 --
386 Begin
387 hr_utility.set_location('Entering:'||l_proc, 5);
388 --
389 -- Call conversion function to turn arguments into the
390 -- p_rec structure.
391 --
392 l_rec :=
393 ben_xwc_shd.convert_args
394 (
395 null,
396 p_seq_num,
397 p_oper_cd,
398 p_val,
399 p_and_or_cd,
400 p_ext_data_elmt_id,
401 p_cond_ext_data_elmt_id,
402 p_ext_rcd_in_file_id,
403 p_ext_data_elmt_in_rcd_id,
404 p_business_group_id,
405 p_legislation_code,
406 p_last_update_date,
407 p_creation_date ,
408 p_last_updated_by ,
409 p_last_update_login,
410 p_created_by,
411 null,
412 p_cond_ext_data_elmt_in_rcd_id
413 );
414 --
415 -- Having converted the arguments into the ben_xwc_rec
416 -- plsql record structure we call the corresponding record business process.
417 --
418 ins(
419 p_effective_date,l_rec);
420 --
421 -- As the primary key argument(s)
422 -- are specified as an OUT's we must set these values.
423 --
424 p_ext_where_clause_id := l_rec.ext_where_clause_id;
425 p_object_version_number := l_rec.object_version_number;
426 --
427 hr_utility.set_location(' Leaving:'||l_proc, 10);
428 End ins;
429 --
430 end ben_xwc_ins;