DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_TPL_INS

Source


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