1 Package Body per_za_eqt_ins as
2 /* $Header: pezaeqin.pkb 115.1 2002/12/05 06:35:32 nsugavan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_za_eqt_ins.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 -- This procedure controls the actual dml insert logic. The processing of
17 -- this procedure are as follows:
18 -- 1) Initialise the object_version_number to 1 if the object_version_number
19 -- is defined as an attribute for this entity.
20 -- 2) To set and unset the g_api_dml status as required (as we are about to
21 -- perform dml).
22 -- 3) To insert the row into the schema.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Pre Conditions:
27 -- This is an internal private procedure which must be called from the ins
28 -- procedure and must have all mandatory attributes set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 -- On the insert dml failure it is important to note that we always reset the
39 -- g_api_dml status to false.
40 -- If a check, unique or parent integrity constraint violation is raised the
41 -- constraint_error procedure will be called.
42 -- If any other error is reported, the error will be raised after the
43 -- g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 -- None.
47 --
48 -- Access Status:
49 -- Internal Table Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out nocopy per_za_eqt_shd.g_rec_type) is
54 --
55 l_proc varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58 hr_utility.set_location('Entering:'||l_proc, 5);
59 p_rec.object_version_number := 1; -- Initialise the object version
60 --
61 per_za_eqt_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: per_qualification_types
64 --
65 insert into per_qualification_types
66 ( qualification_type_id,
67 name,
68 category,
69 rank,
70 attribute_category,
71 attribute1,
72 attribute2,
73 attribute3,
74 attribute4,
75 attribute5,
76 attribute6,
77 attribute7,
78 attribute8,
79 attribute9,
80 attribute10,
81 attribute11,
82 attribute12,
83 attribute13,
84 attribute14,
85 attribute15,
86 attribute16,
87 attribute17,
88 attribute18,
89 attribute19,
90 attribute20,
91 object_version_number
92 )
93 Values
94 ( p_rec.qualification_type_id,
95 p_rec.name,
96 p_rec.category,
97 p_rec.rank,
98 p_rec.attribute_category,
99 p_rec.attribute1,
100 p_rec.attribute2,
101 p_rec.attribute3,
102 p_rec.attribute4,
103 p_rec.attribute5,
104 p_rec.attribute6,
105 p_rec.attribute7,
106 p_rec.attribute8,
107 p_rec.attribute9,
108 p_rec.attribute10,
109 p_rec.attribute11,
110 p_rec.attribute12,
111 p_rec.attribute13,
112 p_rec.attribute14,
113 p_rec.attribute15,
114 p_rec.attribute16,
115 p_rec.attribute17,
116 p_rec.attribute18,
117 p_rec.attribute19,
118 p_rec.attribute20,
119 p_rec.object_version_number
120 );
121
122 insert into per_za_qualification_types(qualification_type_id,
123 nqf_qualification_type)
124 values(p_rec.qualification_type_id,
125 p_rec.nqf_qualification_type);
126 --
127 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
128 --
129 hr_utility.set_location(' Leaving:'||l_proc, 10);
130 Exception
131 When hr_api.check_integrity_violated Then
132 -- A check constraint has been violated
133 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
134 per_za_eqt_shd.constraint_error
135 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
136 When hr_api.parent_integrity_violated Then
137 -- Parent integrity has been violated
138 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
139 per_za_eqt_shd.constraint_error
140 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
141 When hr_api.unique_integrity_violated Then
142 -- Unique integrity has been violated
143 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
144 per_za_eqt_shd.constraint_error
145 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
146 When Others Then
147 per_za_eqt_shd.g_api_dml := false; -- Unset the api dml status
148 Raise;
149 End insert_dml;
150 --
151 -- ----------------------------------------------------------------------------
152 -- |------------------------------< pre_insert >------------------------------|
153 -- ----------------------------------------------------------------------------
154 -- {Start Of Comments}
155 --
156 -- Description:
157 -- This private procedure contains any processing which is required before
158 -- the insert dml. Presently, if the entity has a corresponding primary
159 -- key which is maintained by an associating sequence, the primary key for
160 -- the entity will be populated with the next sequence value in
161 -- preparation for the insert dml.
162 --
163 -- Pre Conditions:
164 -- This is an internal procedure which is called from the ins procedure.
165 --
166 -- In Parameters:
167 -- A Pl/Sql record structre.
168 --
169 -- Post Success:
170 -- Processing continues.
171 --
172 -- Post Failure:
173 -- If an error has occurred, an error message and exception will be raised
174 -- but not handled.
175 --
176 -- Developer Implementation Notes:
177 -- Any pre-processing required before the insert dml is issued should be
178 -- coded within this procedure. As stated above, a good example is the
179 -- generation of a primary key number via a corresponding sequence.
180 -- It is important to note that any 3rd party maintenance should be reviewed
181 -- before placing in this procedure.
182 --
183 -- Access Status:
184 -- Internal Table Handler Use Only.
185 --
186 -- {End Of Comments}
187 -- ----------------------------------------------------------------------------
188 Procedure pre_insert(p_rec in out nocopy per_za_eqt_shd.g_rec_type) is
189 --
190 l_proc varchar2(72) := g_package||'pre_insert';
191 --
192 cursor c1 is
193 select per_qualification_types_s.nextval
194 from sys.dual;
195 --
196 Begin
197 hr_utility.set_location('Entering:'||l_proc, 5);
198 --
199 open c1;
200 --
201 fetch c1 into p_rec.qualification_type_id;
202 --
203 close c1;
204 --
205 hr_utility.set_location(' Leaving:'||l_proc, 10);
206 End pre_insert;
207 --
208 -- ----------------------------------------------------------------------------
209 -- |-----------------------------< post_insert >------------------------------|
210 -- ----------------------------------------------------------------------------
211 -- {Start Of Comments}
212 --
213 -- Description:
214 -- This private procedure contains any processing which is required after the
215 -- insert dml.
216 --
217 -- Pre Conditions:
218 -- This is an internal procedure which is called from the ins procedure.
219 --
220 -- In Parameters:
221 -- A Pl/Sql record structre.
222 --
223 -- Post Success:
224 -- Processing continues.
225 --
226 -- Post Failure:
227 -- If an error has occurred, an error message and exception will be raised
228 -- but not handled.
229 --
230 -- Developer Implementation Notes:
231 -- Any post-processing required after the insert dml is issued should be
232 -- coded within this procedure. It is important to note that any 3rd party
233 -- maintenance should be reviewed before placing in this procedure.
234 --
235 -- Access Status:
236 -- Internal Table Handler Use Only.
237 --
238 -- {End Of Comments}
239 -- ----------------------------------------------------------------------------
240 Procedure post_insert(p_rec in per_za_eqt_shd.g_rec_type) is
241 --
242 l_proc varchar2(72) := g_package||'post_insert';
243 --
244 Begin
245 hr_utility.set_location('Entering:'||l_proc, 5);
246 --
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 End post_insert;
249 --
250 -- ----------------------------------------------------------------------------
251 -- |---------------------------------< ins >----------------------------------|
252 -- ----------------------------------------------------------------------------
253 Procedure ins
254 (
255 p_rec in out nocopy per_za_eqt_shd.g_rec_type,
256 p_effective_date in date,
257 p_validate in boolean default false
258 ) is
259 --
260 l_proc varchar2(72) := g_package||'ins';
261 --
262 Begin
263 hr_utility.set_location('Entering:'||l_proc, 5);
264 --
265 -- Determine if the business process is to be validated.
266 --
267 If p_validate then
268 --
269 -- Issue the savepoint.
270 --
271 SAVEPOINT ins_per_za_eqt;
272 End If;
273 --
274 -- Call the supporting insert validate operations
275 --
276 per_za_eqt_bus.insert_validate(p_rec,p_effective_date);
277 --
278 -- Call the supporting pre-insert operation
279 --
280 pre_insert(p_rec);
281 --
282 -- Insert the row
283 --
284 insert_dml(p_rec);
285 --
286 -- Call the supporting post-insert operation
287 --
288 post_insert(p_rec);
289 --
290 -- If we are validating then raise the Validate_Enabled exception
291 --
292 If p_validate then
293 Raise HR_Api.Validate_Enabled;
294 End If;
295 --
296 hr_utility.set_location(' Leaving:'||l_proc, 10);
297 Exception
298 When HR_Api.Validate_Enabled Then
299 --
300 -- As the Validate_Enabled exception has been raised
301 -- we must rollback to the savepoint
302 --
303 ROLLBACK TO ins_per_za_eqt;
304 end ins;
305 --
306 -- ----------------------------------------------------------------------------
307 -- |---------------------------------< ins >----------------------------------|
308 -- ----------------------------------------------------------------------------
309 Procedure ins
310 (
311 p_qualification_type_id out nocopy number,
312 p_nqf_qualification_type in varchar2,
313 p_name in varchar2,
314 p_category in varchar2,
315 p_rank in number default null,
316 p_attribute_category in varchar2 default null,
317 p_attribute1 in varchar2 default null,
318 p_attribute2 in varchar2 default null,
319 p_attribute3 in varchar2 default null,
320 p_attribute4 in varchar2 default null,
321 p_attribute5 in varchar2 default null,
322 p_attribute6 in varchar2 default null,
323 p_attribute7 in varchar2 default null,
324 p_attribute8 in varchar2 default null,
325 p_attribute9 in varchar2 default null,
326 p_attribute10 in varchar2 default null,
327 p_attribute11 in varchar2 default null,
328 p_attribute12 in varchar2 default null,
329 p_attribute13 in varchar2 default null,
330 p_attribute14 in varchar2 default null,
331 p_attribute15 in varchar2 default null,
332 p_attribute16 in varchar2 default null,
333 p_attribute17 in varchar2 default null,
334 p_attribute18 in varchar2 default null,
335 p_attribute19 in varchar2 default null,
336 p_attribute20 in varchar2 default null,
337 p_object_version_number out nocopy number,
338 p_effective_date in date,
339 p_validate in boolean default false
340 ) is
341 --
342 l_rec per_za_eqt_shd.g_rec_type;
343 l_proc varchar2(72) := g_package||'ins';
344 --
345 Begin
346 hr_utility.set_location('Entering:'||l_proc, 5);
347 --
348 -- Call conversion function to turn arguments into the
349 -- p_rec structure.
350 --
351 l_rec :=
352 per_za_eqt_shd.convert_args
353 (
354 null,
355 p_nqf_qualification_type,
356 p_name,
357 p_category,
358 p_rank,
359 p_attribute_category,
360 p_attribute1,
361 p_attribute2,
362 p_attribute3,
363 p_attribute4,
364 p_attribute5,
365 p_attribute6,
366 p_attribute7,
367 p_attribute8,
368 p_attribute9,
369 p_attribute10,
370 p_attribute11,
371 p_attribute12,
372 p_attribute13,
373 p_attribute14,
374 p_attribute15,
375 p_attribute16,
376 p_attribute17,
377 p_attribute18,
378 p_attribute19,
379 p_attribute20,
380 null
381 );
382 --
383 -- Having converted the arguments into the per_za_eqt_rec
384 -- plsql record structure we call the corresponding record business process.
385 --
386 ins(l_rec,p_effective_date,p_validate);
387 --
388 -- As the primary key argument(s)
389 -- are specified as an OUT's we must set these values.
390 --
391 p_qualification_type_id := l_rec.qualification_type_id;
392 p_object_version_number := l_rec.object_version_number;
393 --
394 hr_utility.set_location(' Leaving:'||l_proc, 10);
395 End ins;
396 --
397 end per_za_eqt_ins;