1 Package Body ota_pmm_ins as
2 /* $Header: otpmm01t.pkb 115.2 99/07/16 00:53:06 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ota_pmm_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 functions of this
17 -- 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 arguments set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Arguments:
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 Development Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml(p_rec in out ota_pmm_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 ota_pmm_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ota_program_memberships
64 --
65 insert into ota_program_memberships
66 ( program_membership_id,
67 event_id,
68 program_event_id,
69 object_version_number,
70 comments,
71 group_name,
72 required_flag,
73 role,
74 sequence,
75 pmm_information_category,
76 pmm_information1,
77 pmm_information2,
78 pmm_information3,
79 pmm_information4,
80 pmm_information5,
81 pmm_information6,
82 pmm_information7,
83 pmm_information8,
84 pmm_information9,
85 pmm_information10,
86 pmm_information11,
87 pmm_information12,
88 pmm_information13,
89 pmm_information14,
90 pmm_information15,
91 pmm_information16,
92 pmm_information17,
93 pmm_information18,
94 pmm_information19,
95 pmm_information20
96 )
97 Values
98 ( p_rec.program_membership_id,
99 p_rec.event_id,
100 p_rec.program_event_id,
101 p_rec.object_version_number,
102 p_rec.comments,
103 p_rec.group_name,
104 p_rec.required_flag,
105 p_rec.role,
106 p_rec.sequence,
107 p_rec.pmm_information_category,
108 p_rec.pmm_information1,
109 p_rec.pmm_information2,
110 p_rec.pmm_information3,
111 p_rec.pmm_information4,
112 p_rec.pmm_information5,
113 p_rec.pmm_information6,
114 p_rec.pmm_information7,
115 p_rec.pmm_information8,
116 p_rec.pmm_information9,
117 p_rec.pmm_information10,
118 p_rec.pmm_information11,
119 p_rec.pmm_information12,
120 p_rec.pmm_information13,
121 p_rec.pmm_information14,
122 p_rec.pmm_information15,
123 p_rec.pmm_information16,
124 p_rec.pmm_information17,
125 p_rec.pmm_information18,
126 p_rec.pmm_information19,
127 p_rec.pmm_information20
128 );
129 --
130 ota_pmm_shd.g_api_dml := false; -- Unset the api dml status
131 --
132 hr_utility.set_location(' Leaving:'||l_proc, 10);
133 Exception
134 When hr_api.check_integrity_violated Then
135 -- A check constraint has been violated
136 ota_pmm_shd.g_api_dml := false; -- Unset the api dml status
137 ota_pmm_shd.constraint_error
138 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
139 When hr_api.parent_integrity_violated Then
140 -- Parent integrity has been violated
141 ota_pmm_shd.g_api_dml := false; -- Unset the api dml status
142 ota_pmm_shd.constraint_error
143 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
144 When hr_api.unique_integrity_violated Then
145 -- Unique integrity has been violated
146 ota_pmm_shd.g_api_dml := false; -- Unset the api dml status
147 ota_pmm_shd.constraint_error
148 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
149 When Others Then
150 ota_pmm_shd.g_api_dml := false; -- Unset the api dml status
151 Raise;
152 End insert_dml;
153 --
154 -- ----------------------------------------------------------------------------
155 -- |------------------------------< pre_insert >------------------------------|
156 -- ----------------------------------------------------------------------------
157 -- {Start Of Comments}
158 --
159 -- Description:
160 -- This private procedure contains any processing which is required before
161 -- the insert dml. Presently, if the entity has a corresponding primary
162 -- key which is maintained by an associating sequence, the primary key for
163 -- the entity will be populated with the next sequence value in
164 -- preparation for the insert dml.
165 --
166 -- Pre Conditions:
167 -- This is an internal procedure which is called from the ins procedure.
168 --
169 -- In Arguments:
170 -- A Pl/Sql record structre.
171 --
172 -- Post Success:
173 -- Processing continues.
174 --
175 -- Post Failure:
176 -- If an error has occurred, an error message and exception will be raised
177 -- but not handled.
178 --
179 -- Developer Implementation Notes:
180 -- Any pre-processing required before the insert dml is issued should be
181 -- coded within this procedure. As stated above, a good example is the
182 -- generation of a primary key number via a corresponding sequence.
183 -- It is important to note that any 3rd party maintenance should be reviewed
184 -- before placing in this procedure.
185 --
186 -- Access Status:
187 -- Internal Development Use Only.
188 --
189 -- {End Of Comments}
190 -- ----------------------------------------------------------------------------
191 Procedure pre_insert(p_rec in out ota_pmm_shd.g_rec_type) is
192 --
193 l_proc varchar2(72) := g_package||'pre_insert';
194 --
195 Cursor C_Sel1 is select ota_program_memberships_s.nextval from sys.dual;
196 --
197 Begin
198 hr_utility.set_location('Entering:'||l_proc, 5);
199 --
200 --
201 -- Select the next sequence number
202 --
203 Open C_Sel1;
204 Fetch C_Sel1 Into p_rec.program_membership_id;
205 Close C_Sel1;
206 --
207 hr_utility.set_location(' Leaving:'||l_proc, 10);
208 End pre_insert;
209 --
210 -- ----------------------------------------------------------------------------
211 -- |-----------------------------< post_insert >------------------------------|
212 -- ----------------------------------------------------------------------------
213 -- {Start Of Comments}
214 --
215 -- Description:
216 -- This private procedure contains any processing which is required after the
217 -- insert dml.
218 --
219 -- Pre Conditions:
220 -- This is an internal procedure which is called from the ins procedure.
221 --
222 -- In Arguments:
223 -- A Pl/Sql record structre.
224 --
225 -- Post Success:
226 -- Processing continues.
227 --
228 -- Post Failure:
229 -- If an error has occurred, an error message and exception will be raised
230 -- but not handled.
231 --
232 -- Developer Implementation Notes:
233 -- Any post-processing required after the insert dml is issued should be
234 -- coded within this procedure. It is important to note that any 3rd party
235 -- maintenance should be reviewed before placing in this procedure.
236 --
237 -- Access Status:
238 -- Internal Development Use Only.
239 --
240 -- {End Of Comments}
241 -- ----------------------------------------------------------------------------
242 Procedure post_insert(p_rec in ota_pmm_shd.g_rec_type) is
243 --
244 l_proc varchar2(72) := g_package||'post_insert';
245 --
246 Begin
247 hr_utility.set_location('Entering:'||l_proc, 5);
248 --
249 hr_utility.set_location(' Leaving:'||l_proc, 10);
250 End post_insert;
251 --
252 -- ----------------------------------------------------------------------------
253 -- |---------------------------------< ins >----------------------------------|
254 -- ----------------------------------------------------------------------------
255 Procedure ins
256 (
257 p_rec in out ota_pmm_shd.g_rec_type,
258 p_validate in boolean default false
259 ) is
260 --
261 l_proc varchar2(72) := g_package||'ins';
262 --
263 Begin
264 hr_utility.set_location('Entering:'||l_proc, 5);
265 --
266 -- Determine if the business process is to be validated.
267 --
268 If p_validate then
269 --
270 -- Issue the savepoint.
271 --
272 SAVEPOINT ins_ota_pmm;
273 End If;
274 --
275 -- Call the supporting insert validate operations
276 --
277 ota_pmm_bus.insert_validate(p_rec);
278 --
279 -- Call the supporting pre-insert operation
280 --
281 pre_insert(p_rec);
282 --
283 -- Insert the row
284 --
285 insert_dml(p_rec);
286 --
287 -- Call the supporting post-insert operation
288 --
289 post_insert(p_rec);
290 --
291 -- If we are validating then raise the Validate_Enabled exception
292 --
293 If p_validate then
294 Raise HR_Api.Validate_Enabled;
295 End If;
296 --
297 hr_utility.set_location(' Leaving:'||l_proc, 10);
298 Exception
299 When HR_Api.Validate_Enabled Then
300 --
301 -- As the Validate_Enabled exception has been raised
302 -- we must rollback to the savepoint
303 --
304 ROLLBACK TO ins_ota_pmm;
305 end ins;
306 --
307 -- ----------------------------------------------------------------------------
308 -- |---------------------------------< ins >----------------------------------|
309 -- ----------------------------------------------------------------------------
310 Procedure ins
311 (
312 p_program_membership_id out number,
313 p_event_id in number,
314 p_program_event_id in number,
315 p_object_version_number out number,
316 p_comments in varchar2 default null,
317 p_group_name in varchar2 default null,
318 p_required_flag in varchar2 default null,
319 p_role in varchar2 default null,
320 p_sequence in number default null,
321 p_pmm_information_category in varchar2 default null,
322 p_pmm_information1 in varchar2 default null,
323 p_pmm_information2 in varchar2 default null,
324 p_pmm_information3 in varchar2 default null,
325 p_pmm_information4 in varchar2 default null,
326 p_pmm_information5 in varchar2 default null,
327 p_pmm_information6 in varchar2 default null,
328 p_pmm_information7 in varchar2 default null,
329 p_pmm_information8 in varchar2 default null,
330 p_pmm_information9 in varchar2 default null,
331 p_pmm_information10 in varchar2 default null,
332 p_pmm_information11 in varchar2 default null,
333 p_pmm_information12 in varchar2 default null,
334 p_pmm_information13 in varchar2 default null,
335 p_pmm_information14 in varchar2 default null,
336 p_pmm_information15 in varchar2 default null,
337 p_pmm_information16 in varchar2 default null,
338 p_pmm_information17 in varchar2 default null,
339 p_pmm_information18 in varchar2 default null,
340 p_pmm_information19 in varchar2 default null,
341 p_pmm_information20 in varchar2 default null,
342 p_validate in boolean default false
343 ) is
344 --
345 l_rec ota_pmm_shd.g_rec_type;
346 l_proc varchar2(72) := g_package||'ins';
347 --
348 Begin
349 hr_utility.set_location('Entering:'||l_proc, 5);
350 --
351 -- Call conversion function to turn arguments into the
352 -- p_rec structure.
353 --
354 l_rec :=
355 ota_pmm_shd.convert_args
356 (
357 null,
358 p_event_id,
359 p_program_event_id,
360 null,
361 p_comments,
362 p_group_name,
363 p_required_flag,
364 p_role,
365 p_sequence,
366 p_pmm_information_category,
367 p_pmm_information1,
368 p_pmm_information2,
369 p_pmm_information3,
370 p_pmm_information4,
371 p_pmm_information5,
372 p_pmm_information6,
373 p_pmm_information7,
374 p_pmm_information8,
375 p_pmm_information9,
376 p_pmm_information10,
377 p_pmm_information11,
378 p_pmm_information12,
379 p_pmm_information13,
380 p_pmm_information14,
381 p_pmm_information15,
382 p_pmm_information16,
383 p_pmm_information17,
384 p_pmm_information18,
385 p_pmm_information19,
386 p_pmm_information20
387 );
388 --
389 -- Having converted the arguments into the ota_pmm_rec
390 -- plsql record structure we call the corresponding record business process.
391 --
392 ins(l_rec, p_validate);
393 --
394 -- As the primary key argument(s)
395 -- are specified as an OUT's we must set these values.
396 --
397 p_program_membership_id := l_rec.program_membership_id;
398 p_object_version_number := l_rec.object_version_number;
399 --
400 hr_utility.set_location(' Leaving:'||l_proc, 10);
401 End ins;
402 --
403 end ota_pmm_ins;