1 Package Body per_za_ass_ins as
2 /* $Header: pezaasin.pkb 115.1 2002/12/05 06:49:27 nsugavan noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' per_za_ass_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_ass_shd.g_za_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
60 --
61 per_za_ass_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: per_za_assessments
64 --
65 insert into per_za_assessments (
66 assessment_id,
67 person_id,
68 level_id,
69 name_of_assessor,
70 institution,
71 credit,
72 date_of_assessment,
73 final_result,
74 assessment_number,
75 location_where_assessed,
76 field_of_learning,
77 sub_field,
78 assessment_start_date,
79 assessment_end_date,
80 competence_acquired,
81 ETQA_name,
82 certification_date,
83 certificate_number,
84 accredited_by,
85 date_of_accreditation,
86 certification_expiry_date
87 )
88 Values
89 (
90 p_rec.assessment_id,
91 p_rec.person_id,
92 p_rec.level_id,
93 p_rec.name_of_assessor,
94 p_rec.institution,
95 p_rec.credit,
96 p_rec.date_of_assessment,
97 p_rec.final_result,
98 p_rec.assessment_number,
99 p_rec.location_where_assessed,
100 p_rec.field_of_learning,
101 p_rec.sub_field,
102 p_rec.assessment_start_date,
103 p_rec.assessment_end_date,
104 p_rec.competence_acquired,
105 p_rec.ETQA_name,
106 p_rec.certification_date,
107 p_rec.certificate_number,
108 p_rec.accredited_by,
109 p_rec.date_of_accreditation,
110 p_rec.certification_expiry_date
111 );
112 --
113 per_za_ass_shd.g_api_dml := false; -- Unset the api dml status
114 --
115 hr_utility.set_location(' Leaving:'||l_proc, 10);
116 Exception
117 When hr_api.check_integrity_violated Then
118 -- A check constraint has been violated
119 per_za_ass_shd.g_api_dml := false; -- Unset the api dml status
120 per_za_ass_shd.constraint_error
121 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122 When hr_api.parent_integrity_violated Then
123 -- Parent integrity has been violated
124 per_za_ass_shd.g_api_dml := false; -- Unset the api dml status
125 per_za_ass_shd.constraint_error
126 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127 When hr_api.unique_integrity_violated Then
128 -- Unique integrity has been violated
129 per_za_ass_shd.g_api_dml := false; -- Unset the api dml status
130 per_za_ass_shd.constraint_error
131 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
132 When Others Then
133 per_za_ass_shd.g_api_dml := false; -- Unset the api dml status
134 Raise;
135 End insert_dml;
136
137 -- ----------------------------------------------------------------------------
138 -- |-----------------------------< post_insert >------------------------------|
139 -- ----------------------------------------------------------------------------
140 -- {Start Of Comments}
141 --
142 -- Description:
143 -- This private procedure contains any processing which is required after the
144 -- insert dml.
145 --
146 -- Pre Conditions:
147 -- This is an internal procedure which is called from the ins procedure.
148 --
149 -- In Parameters:
150 -- A Pl/Sql record structre.
151 --
152 -- Post Success:
153 -- Processing continues.
154 --
155 -- Post Failure:
156 -- If an error has occurred, an error message and exception will be raised
157 -- but not handled.
158 --
159 -- Developer Implementation Notes:
160 -- Any post-processing required after the insert dml is issued should be
161 -- coded within this procedure. It is important to note that any 3rd party
162 -- maintenance should be reviewed before placing in this procedure.
163 --
164 -- Access Status:
165 -- Internal Table Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure post_insert(p_rec in per_za_ass_shd.g_za_rec_type) is
170 --
171 l_proc varchar2(72) := g_package||'post_insert';
172 --
173 Begin
174 hr_utility.set_location('Entering:'||l_proc, 5);
175 --
176 hr_utility.set_location(' Leaving:'||l_proc, 10);
177 End post_insert;
178 --
179 -- ----------------------------------------------------------------------------
180 -- |---------------------------------< ins >----------------------------------|
181 -- ----------------------------------------------------------------------------
182 Procedure ins
183 (
184 p_rec in out nocopy per_za_ass_shd.g_za_rec_type,
185 p_validate in boolean default false
186 ) is
187 --
188 l_proc varchar2(72) := g_package||'ins';
189 --
190 Begin
191 hr_utility.set_location('Entering:'||l_proc, 5);
192 --
193 -- Determine if the business process is to be validated.
194 --
195 If p_validate then
196 --
197 -- Issue the savepoint.
198 --
199 SAVEPOINT ins_ass;
200 End If;
201
202 --
203 -- Insert the row
204 --
205 insert_dml(p_rec);
206 --
207 -- Call the supporting post-insert operation
208 --
209 post_insert(p_rec);
210 --
211 -- If we are validating then raise the Validate_Enabled exception
212 --
213 If p_validate then
214 Raise HR_Api.Validate_Enabled;
215 End If;
216 --
217 hr_utility.set_location(' Leaving:'||l_proc, 10);
218 Exception
219 When HR_Api.Validate_Enabled Then
220 --
221 -- As the Validate_Enabled exception has been raised
222 -- we must rollback to the savepoint
223 --
224 ROLLBACK TO ins_ass;
225 end ins;
226 --
227 -- ----------------------------------------------------------------------------
228 -- |---------------------------------< ins >----------------------------------|
229 -- ----------------------------------------------------------------------------
230 Procedure ins
231 (
232 p_assessment_id in number,
233 p_person_id in number,
234 p_level_id in number default null,
235 p_name_of_assessor in varchar2,
236 p_institution in varchar2 default null,
237 p_credit in number default null,
238 p_date_of_assessment in date default null,
239 p_final_result in varchar2 default null,
240 p_assessment_number in varchar2 default null,
241 p_location_where_assessed in varchar2 default null,
242 p_field_of_learning in varchar2 default null,
243 p_sub_field in varchar2 default null,
244 p_assessment_start_date in date default null,
245 p_assessment_end_date in date default null,
246 p_competence_acquired in varchar2 default null,
247 p_ETQA_name in varchar2 default null,
248 p_certification_date in date default null,
249 p_certificate_number in varchar2 default null,
250 p_accredited_by in varchar2 default null,
251 p_date_of_accreditation in date default null,
252 p_certification_expiry_date in date default null,
253 p_validate in boolean default false
254 ) is
255 --
256 l_rec per_za_ass_shd.g_za_rec_type;
257 l_proc varchar2(72) := g_package||'ins';
258 --
259 Begin
260 hr_utility.set_location('Entering:'||l_proc, 5);
261 --
262 -- Call conversion function to turn arguments into the
263 -- p_rec structure.
264 --
265 l_rec :=
266 per_za_ass_shd.convert_args
267 (
268 p_assessment_id,
269 p_person_id,
270 p_level_id,
271 p_name_of_assessor,
272 p_institution,
273 p_credit,
274 p_date_of_assessment,
275 p_final_result,
276 p_assessment_number,
277 p_location_where_assessed,
278 p_field_of_learning,
279 p_sub_field,
280 p_assessment_start_date,
281 p_assessment_end_date,
282 p_competence_acquired,
283 p_ETQA_name,
284 p_certification_date,
285 p_certificate_number,
286 p_accredited_by,
287 p_date_of_accreditation,
288 p_certification_expiry_date
289 );
290 --
291 -- Having converted the arguments into the ass_rec
292 -- plsql record structure we call the corresponding record business process.
293 --
294 ins(l_rec, p_validate);
295 --
296 -- As the primary key argument(s)
297 -- are specified as an OUT's we must set these values.
298 --
299 --
300 hr_utility.set_location(' Leaving:'||l_proc, 10);
301 End ins;
302 --
303 end per_za_ass_ins;