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