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