DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_PLE_INS

Source


1 Package Body ota_ple_ins as
2 /* $Header: otple01t.pkb 115.3 99/07/16 00:52:56 porting ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ota_ple_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_ple_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_ple_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ota_price_list_entries
64   --
65   insert into ota_price_list_entries
66   (	price_list_entry_id,
67 	vendor_supply_id,
68 	activity_version_id,
69 	price_list_id,
70 	object_version_number,
71 	price,
72 	price_basis,
73 	start_date,
74 	comments,
75 	end_date,
76 	maximum_attendees,
77 	minimum_attendees,
78 	ple_information_category,
79 	ple_information1,
80 	ple_information2,
81 	ple_information3,
82 	ple_information4,
83 	ple_information5,
84 	ple_information6,
85 	ple_information7,
86 	ple_information8,
87 	ple_information9,
88 	ple_information10,
89 	ple_information11,
90 	ple_information12,
91 	ple_information13,
92 	ple_information14,
93 	ple_information15,
94 	ple_information16,
95 	ple_information17,
96 	ple_information18,
97 	ple_information19,
98 	ple_information20
99   )
100   Values
101   (	p_rec.price_list_entry_id,
102 	p_rec.vendor_supply_id,
103 	p_rec.activity_version_id,
104 	p_rec.price_list_id,
105 	p_rec.object_version_number,
106 	p_rec.price,
107 	p_rec.price_basis,
108 	p_rec.start_date,
109 	p_rec.comments,
110 	p_rec.end_date,
111 	p_rec.maximum_attendees,
112 	p_rec.minimum_attendees,
113 	p_rec.ple_information_category,
114 	p_rec.ple_information1,
115 	p_rec.ple_information2,
116 	p_rec.ple_information3,
117 	p_rec.ple_information4,
118 	p_rec.ple_information5,
119 	p_rec.ple_information6,
120 	p_rec.ple_information7,
121 	p_rec.ple_information8,
122 	p_rec.ple_information9,
123 	p_rec.ple_information10,
124 	p_rec.ple_information11,
125 	p_rec.ple_information12,
126 	p_rec.ple_information13,
127 	p_rec.ple_information14,
128 	p_rec.ple_information15,
129 	p_rec.ple_information16,
130 	p_rec.ple_information17,
131 	p_rec.ple_information18,
132 	p_rec.ple_information19,
133 	p_rec.ple_information20
134   );
135   --
136   ota_ple_shd.g_api_dml := false;   -- Unset the api dml status
137   --
138   hr_utility.set_location(' Leaving:'||l_proc, 10);
139 Exception
140   When hr_api.check_integrity_violated Then
141     -- A check constraint has been violated
142     ota_ple_shd.g_api_dml := false;   -- Unset the api dml status
143     ota_ple_shd.constraint_error
144       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
145   When hr_api.parent_integrity_violated Then
146     -- Parent integrity has been violated
147     ota_ple_shd.g_api_dml := false;   -- Unset the api dml status
148     ota_ple_shd.constraint_error
149       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
150   When hr_api.unique_integrity_violated Then
151     -- Unique integrity has been violated
152     ota_ple_shd.g_api_dml := false;   -- Unset the api dml status
153     ota_ple_shd.constraint_error
154       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
155   When Others Then
156     ota_ple_shd.g_api_dml := false;   -- Unset the api dml status
157     Raise;
158 End insert_dml;
159 --
160 -- ----------------------------------------------------------------------------
161 -- |------------------------------< pre_insert >------------------------------|
162 -- ----------------------------------------------------------------------------
163 -- {Start Of Comments}
164 --
165 -- Description:
166 --   This private procedure contains any processing which is required before
167 --   the insert dml. Presently, if the entity has a corresponding primary
168 --   key which is maintained by an associating sequence, the primary key for
169 --   the entity will be populated with the next sequence value in
170 --   preparation for the insert dml.
171 --
172 -- Pre Conditions:
173 --   This is an internal procedure which is called from the ins procedure.
174 --
175 -- In Arguments:
176 --   A Pl/Sql record structre.
177 --
178 -- Post Success:
179 --   Processing continues.
180 --
181 -- Post Failure:
182 --   If an error has occurred, an error message and exception will be raised
183 --   but not handled.
184 --
185 -- Developer Implementation Notes:
186 --   Any pre-processing required before the insert dml is issued should be
187 --   coded within this procedure. As stated above, a good example is the
188 --   generation of a primary key number via a corresponding sequence.
189 --   It is important to note that any 3rd party maintenance should be reviewed
190 --   before placing in this procedure.
191 --
192 -- Access Status:
193 --   Internal Development Use Only.
194 --
195 -- {End Of Comments}
196 -- ----------------------------------------------------------------------------
197 Procedure pre_insert(p_rec  in out ota_ple_shd.g_rec_type) is
198 --
199   l_proc  varchar2(72) := g_package||'pre_insert';
200 --
201   Cursor C_Sel1 is select ota_price_list_entries_s.nextval from sys.dual;
202 --
203 Begin
204   hr_utility.set_location('Entering:'||l_proc, 5);
205   --
206   --
207   -- Select the next sequence number
208   --
209   Open C_Sel1;
210   Fetch C_Sel1 Into p_rec.price_list_entry_id;
211   Close C_Sel1;
212   --
213   hr_utility.set_location(' Leaving:'||l_proc, 10);
214 End pre_insert;
215 --
216 -- ----------------------------------------------------------------------------
217 -- |-----------------------------< post_insert >------------------------------|
218 -- ----------------------------------------------------------------------------
219 -- {Start Of Comments}
220 --
221 -- Description:
222 --   This private procedure contains any processing which is required after the
223 --   insert dml.
224 --
225 -- Pre Conditions:
226 --   This is an internal procedure which is called from the ins procedure.
227 --
228 -- In Arguments:
229 --   A Pl/Sql record structre.
230 --
231 -- Post Success:
232 --   Processing continues.
233 --
234 -- Post Failure:
235 --   If an error has occurred, an error message and exception will be raised
236 --   but not handled.
237 --
238 -- Developer Implementation Notes:
239 --   Any post-processing required after the insert dml is issued should be
240 --   coded within this procedure. It is important to note that any 3rd party
241 --   maintenance should be reviewed before placing in this procedure.
242 --
243 -- Access Status:
244 --   Internal Development Use Only.
245 --
246 -- {End Of Comments}
247 -- ----------------------------------------------------------------------------
248 Procedure post_insert(p_rec in ota_ple_shd.g_rec_type) is
249 --
250   l_proc  varchar2(72) := g_package||'post_insert';
251 --
252 Begin
253   hr_utility.set_location('Entering:'||l_proc, 5);
254   --
255   hr_utility.set_location(' Leaving:'||l_proc, 10);
256 End post_insert;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |---------------------------------< ins >----------------------------------|
260 -- ----------------------------------------------------------------------------
261 Procedure ins
262   (
263   p_rec        in out ota_ple_shd.g_rec_type,
264   p_validate   in     boolean default false
265   ) is
266 --
267   l_proc  varchar2(72) := g_package||'ins';
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   --
272   -- Determine if the business process is to be validated.
273   --
274   If p_validate then
275     --
276     -- Issue the savepoint.
277     --
278     SAVEPOINT ins_ota_ple;
279   End If;
280   --
281   -- Call the supporting insert validate operations
282   --
283   ota_ple_bus.insert_validate(p_rec);
284   --
285   -- Call the supporting pre-insert operation
286   --
287   pre_insert(p_rec);
288   --
289   -- Insert the row
290   --
291   insert_dml(p_rec);
292   --
293   -- Call the supporting post-insert operation
294   --
295   post_insert(p_rec);
296   --
297   -- If we are validating then raise the Validate_Enabled exception
298   --
299   If p_validate then
300     Raise HR_Api.Validate_Enabled;
301   End If;
302   --
303   hr_utility.set_location(' Leaving:'||l_proc, 10);
304 Exception
305   When HR_Api.Validate_Enabled Then
306     --
307     -- As the Validate_Enabled exception has been raised
308     -- we must rollback to the savepoint
309     --
310     ROLLBACK TO ins_ota_ple;
311 end ins;
312 --
313 -- ----------------------------------------------------------------------------
314 -- |---------------------------------< ins >----------------------------------|
315 -- ----------------------------------------------------------------------------
316 Procedure ins
317   (
318   p_price_list_entry_id          out number,
319   p_vendor_supply_id             in number           default null,
320   p_activity_version_id          in number           default null,
321   p_price_list_id                in number,
322   p_object_version_number        out number,
323   p_price                        in number,
324   p_price_basis                  in varchar2,
325   p_start_date                   in date,
326   p_comments                     in varchar2         default null,
327   p_end_date                     in date             default null,
328   p_maximum_attendees            in number           default null,
329   p_minimum_attendees            in number           default null,
330   p_ple_information_category     in varchar2         default null,
331   p_ple_information1             in varchar2         default null,
332   p_ple_information2             in varchar2         default null,
333   p_ple_information3             in varchar2         default null,
334   p_ple_information4             in varchar2         default null,
335   p_ple_information5             in varchar2         default null,
336   p_ple_information6             in varchar2         default null,
337   p_ple_information7             in varchar2         default null,
338   p_ple_information8             in varchar2         default null,
339   p_ple_information9             in varchar2         default null,
340   p_ple_information10            in varchar2         default null,
341   p_ple_information11            in varchar2         default null,
342   p_ple_information12            in varchar2         default null,
343   p_ple_information13            in varchar2         default null,
344   p_ple_information14            in varchar2         default null,
345   p_ple_information15            in varchar2         default null,
346   p_ple_information16            in varchar2         default null,
347   p_ple_information17            in varchar2         default null,
348   p_ple_information18            in varchar2         default null,
349   p_ple_information19            in varchar2         default null,
350   p_ple_information20            in varchar2         default null,
351   p_validate                     in boolean   default false
352   ) is
353 --
354   l_rec	  ota_ple_shd.g_rec_type;
355   l_proc  varchar2(72) := g_package||'ins';
356 --
357 Begin
358   hr_utility.set_location('Entering:'||l_proc, 5);
359   --
360   -- Call conversion function to turn arguments into the
361   -- p_rec structure.
362   --
363   l_rec :=
364   ota_ple_shd.convert_args
365   (
366   null,
367   p_vendor_supply_id,
368   p_activity_version_id,
369   p_price_list_id,
370   null,
371   p_price,
372   p_price_basis,
373   p_start_date,
374   p_comments,
375   p_end_date,
376   p_maximum_attendees,
377   p_minimum_attendees,
378   p_ple_information_category,
379   p_ple_information1,
380   p_ple_information2,
381   p_ple_information3,
382   p_ple_information4,
383   p_ple_information5,
384   p_ple_information6,
385   p_ple_information7,
386   p_ple_information8,
387   p_ple_information9,
388   p_ple_information10,
389   p_ple_information11,
390   p_ple_information12,
391   p_ple_information13,
392   p_ple_information14,
393   p_ple_information15,
394   p_ple_information16,
395   p_ple_information17,
396   p_ple_information18,
397   p_ple_information19,
398   p_ple_information20
399   );
400   --
401   -- Having converted the arguments into the ota_ple_rec
402   -- plsql record structure we call the corresponding record business process.
403   --
404   ins(l_rec, p_validate);
405   --
406   -- As the primary key argument(s)
407   -- are specified as an OUT's we must set these values.
408   --
409   p_price_list_entry_id := l_rec.price_list_entry_id;
410   p_object_version_number := l_rec.object_version_number;
411   --
412   hr_utility.set_location(' Leaving:'||l_proc, 10);
413 End ins;
414 --
415 end ota_ple_ins;