DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RHA_INS

Source


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