DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_CPA_INS

Source


1 Package Body per_cpa_ins as
2 /* $Header: pecparhi.pkb 115.4 2002/12/04 15:03:48 pkakar noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)    := '  per_cpa_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 -- Prerequisites:
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:
41 --   constraint_error procedure will be called.
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
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 Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml
54   (p_rec in out nocopy per_cpa_shd.g_rec_type
55   ) is
56 --
57   l_proc  varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60   hr_utility.set_location('Entering:'||l_proc, 5);
61   p_rec.object_version_number := 1;  -- Initialise the object version
62   --
63   --
64   --
65   -- Insert the row into: per_cagr_api_parameters
66   --
67   insert into per_cagr_api_parameters
68       (cagr_api_param_id
69       ,cagr_api_id
70       ,display_name
71       ,parameter_name
72       ,column_type
73       ,column_size
74       ,uom_parameter
75       ,uom_lookup
76 	  ,default_uom
77 	  ,hidden
78       ,object_version_number
79       )
80   Values
81     (p_rec.cagr_api_param_id
82     ,p_rec.cagr_api_id
83     ,p_rec.display_name
84     ,p_rec.parameter_name
85     ,p_rec.column_type
86     ,p_rec.column_size
87     ,p_rec.uom_parameter
88     ,p_rec.uom_lookup
89 	,p_rec.default_uom
90 	,p_rec.hidden
91     ,p_rec.object_version_number
92     );
93   --
94   --
95   --
96   hr_utility.set_location(' Leaving:'||l_proc, 10);
97 Exception
98   When hr_api.check_integrity_violated Then
99     -- A check constraint has been violated
100     --
101     per_cpa_shd.constraint_error
102       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103   When hr_api.parent_integrity_violated Then
104     -- Parent integrity has been violated
105     --
106     per_cpa_shd.constraint_error
107       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108   When hr_api.unique_integrity_violated Then
109     -- Unique integrity has been violated
110     --
111     per_cpa_shd.constraint_error
112       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113   When Others Then
114     --
115     Raise;
116 End insert_dml;
117 --
118 -- ----------------------------------------------------------------------------
119 -- |------------------------------< pre_insert >------------------------------|
120 -- ----------------------------------------------------------------------------
121 -- {Start Of Comments}
122 --
123 -- Description:
124 --   This private procedure contains any processing which is required before
125 --   the insert dml. Presently, if the entity has a corresponding primary
126 --   key which is maintained by an associating sequence, the primary key for
127 --   the entity will be populated with the next sequence value in
128 --   preparation for the insert dml.
129 --
130 -- Prerequisites:
131 --   This is an internal procedure which is called from the ins procedure.
132 --
133 -- In Parameters:
134 --   A Pl/Sql record structre.
135 --
136 -- Post Success:
137 --   Processing continues.
138 --
139 -- Post Failure:
140 --   If an error has occurred, an error message and exception will be raised
141 --   but not handled.
142 --
143 -- Developer Implementation Notes:
144 --   Any pre-processing required before the insert dml is issued should be
145 --   coded within this procedure. As stated above, a good example is the
146 --   generation of a primary key number via a corresponding sequence.
147 --   It is important to note that any 3rd party maintenance should be reviewed
148 --   before placing in this procedure.
149 --
150 -- Access Status:
151 --   Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure pre_insert
156   (p_rec  in out nocopy per_cpa_shd.g_rec_type
157   ) is
158 --
159   l_proc  varchar2(72) := g_package||'pre_insert';
160 --
161   Cursor C_Sel1 is select per_cagr_api_parameters_s.nextval from sys.dual;
162 --
163 Begin
164   hr_utility.set_location('Entering:'||l_proc, 5);
165   --
166   --
167   -- Select the next sequence number
168   --
169   Open C_Sel1;
170   Fetch C_Sel1 Into p_rec.cagr_api_param_id;
171   Close C_Sel1;
172   --
173   hr_utility.set_location(' Leaving:'||l_proc, 10);
174 End pre_insert;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |-----------------------------< post_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 --   This private procedure contains any processing which is required after the
183 --   insert dml.
184 --
185 -- Prerequisites:
186 --   This is an internal procedure which is called from the ins procedure.
187 --
188 -- In Parameters:
189 --   A Pl/Sql record structre.
190 --
191 -- Post Success:
192 --   Processing continues.
196 --   but not handled.
193 --
194 -- Post Failure:
195 --   If an error has occurred, an error message and exception will be raised
197 --
198 -- Developer Implementation Notes:
199 --   Any post-processing required after the insert dml is issued should be
200 --   coded within this procedure. It is important to note that any 3rd party
201 --   maintenance should be reviewed before placing in this procedure.
202 --
203 -- Access Status:
204 --   Internal Row Handler Use Only.
205 --
206 -- {End Of Comments}
207 -- ----------------------------------------------------------------------------
208 Procedure post_insert
209   (p_effective_date               in date
210   ,p_rec                          in per_cpa_shd.g_rec_type
211   ) is
212 --
213   l_proc  varchar2(72) := g_package||'post_insert';
214 --
215 Begin
216   hr_utility.set_location('Entering:'||l_proc, 5);
217   /*
218   begin
219     --
220 	/*
221     per_cpa_rki.after_insert
222       (p_effective_date        => p_effective_date
223       ,p_cagr_api_param_id     => p_rec.cagr_api_param_id
224       ,p_cagr_api_id           => p_rec.cagr_api_id
225       ,p_display_name          => p_rec.display_name
226       ,p_parameter_name        => p_rec.parameter_name
227       ,p_column_type           => p_rec.column_type
228       ,p_column_size           => p_rec.column_size
229       ,p_uom_parameter         => p_rec.uom_parameter
230       ,p_uom_lookup            => p_rec.uom_lookup
231 	  ,p_default_uom           => p_rec.default_uom
232       ,p_object_version_number => p_rec.object_version_number
233       );
234     --
235   exception
236     --
237     when hr_api.cannot_find_prog_unit then
238       --
239       hr_api.cannot_find_prog_unit_error
240         (p_module_name => 'PER_CAGR_API_PARAMETERS'
241         ,p_hook_type   => 'AI');
242       --
243   end;
244   */
245   --
246   hr_utility.set_location(' Leaving:'||l_proc, 10);
247 End post_insert;
248 --
249 -- ----------------------------------------------------------------------------
250 -- |---------------------------------< ins >----------------------------------|
251 -- ----------------------------------------------------------------------------
252 Procedure ins
253   (p_effective_date               in date
254   ,p_rec                          in out nocopy per_cpa_shd.g_rec_type
255   ) is
256 --
257   l_proc  varchar2(72) := g_package||'ins';
258 --
259 Begin
260   hr_utility.set_location('Entering:'||l_proc, 5);
261   --
262   -- Call the supporting insert validate operations
263   --
264   per_cpa_bus.insert_validate
265      (p_effective_date
266      ,p_rec
267      );
268   --
269   -- Call the supporting pre-insert operation
270   --
271   per_cpa_ins.pre_insert(p_rec);
272   --
273   -- Insert the row
274   --
275   per_cpa_ins.insert_dml(p_rec);
276   --
277   -- Call the supporting post-insert operation
278   --
279   /*per_cpa_ins.post_insert
280      (p_effective_date
281      ,p_rec
282      ); */
283   --
284   hr_utility.set_location('Leaving:'||l_proc, 20);
285 end ins;
286 --
287 -- ----------------------------------------------------------------------------
288 -- |---------------------------------< ins >----------------------------------|
289 -- ----------------------------------------------------------------------------
290 Procedure ins
291   (p_effective_date                 in     date
292   ,p_cagr_api_id                    in     number
293   ,p_display_name                   in     varchar2 default null
294   ,p_parameter_name                 in     varchar2 default null
295   ,p_column_type                    in     varchar2 default null
296   ,p_column_size                    in     number   default null
297   ,p_uom_parameter                  in     varchar2 default null
298   ,p_uom_lookup                     in     varchar2 default null
299   ,p_default_uom                    in     varchar2 default null
300   ,p_hidden                         in     varchar2
301   ,p_cagr_api_param_id                 out nocopy number
302   ,p_object_version_number             out nocopy number
303   ) is
304 --
305   l_rec      per_cpa_shd.g_rec_type;
306   l_proc  varchar2(72) := g_package||'ins';
307 --
308 Begin
309   hr_utility.set_location('Entering:'||l_proc, 5);
310   --
311   -- Call conversion function to turn arguments into the
312   -- p_rec structure.
313   --
314   l_rec :=
315   per_cpa_shd.convert_args
316     (null
317     ,p_cagr_api_id
318     ,p_display_name
319     ,p_parameter_name
320     ,p_column_type
321     ,p_column_size
322     ,p_uom_parameter
323     ,p_uom_lookup
324 	,p_default_uom
325 	,p_hidden
326     ,null
327     );
328   --
329   -- Having converted the arguments into the per_cpa_rec
330   -- plsql record structure we call the corresponding record business process.
331   --
332   per_cpa_ins.ins
333     (p_effective_date
334     ,l_rec
335      );
336   --
337   -- As the primary key argument(s)
338   -- are specified as an OUT's we must set these values.
339   --
340   p_cagr_api_param_id := l_rec.cagr_api_param_id;
341   p_object_version_number := l_rec.object_version_number;
342   --
343   hr_utility.set_location(' Leaving:'||l_proc, 10);
344 End ins;
345 --
346 end per_cpa_ins;