DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_RTC_INS

Source


1 Package Body hxc_rtc_ins as
2 /* $Header: hxcrtcrhi.pkb 120.2 2005/09/23 08:51:07 nissharm noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  hxc_rtc_ins.';  -- Global package name
9 
10 g_debug boolean := hr_utility.debug_enabled;
11 --
12 -- ----------------------------------------------------------------------------
13 -- |------------------------------< insert_dml >------------------------------|
14 -- ----------------------------------------------------------------------------
15 -- {Start Of Comments}
16 --
17 -- Description:
18 --   This procedure controls the actual dml insert logic. The processing of
19 --   this procedure are as follows:
20 --   1) Initialise the object_version_number to 1 if the object_version_number
21 --      is defined as an attribute for this entity.
22 --   2) To set and unset the g_api_dml status as required (as we are about to
23 --      perform dml).
24 --   3) To insert the row into the schema.
25 --   4) To trap any constraint violations that may have occurred.
26 --   5) To raise any other errors.
27 --
28 -- Prerequisites:
29 --   This is an internal private procedure which must be called from the ins
30 --   procedure and must have all mandatory attributes set (except the
31 --   object_version_number which is initialised within this procedure).
32 --
33 -- In Parameters:
34 --   A Pl/Sql record structre.
35 --
36 -- Post Success:
37 --   The specified row will be inserted into the schema.
38 --
39 -- Post Failure:
40 --   On the insert dml failure it is important to note that we always reset the
41 --   g_api_dml status to false.
42 --   If a check, unique or parent integrity constraint violation is raised the
43 --   constraint_error procedure will be called.
44 --   If any other error is reported, the error will be raised after the
45 --   g_api_dml status is reset.
46 --
47 -- Developer Implementation Notes:
48 --   None.
49 --
50 -- Access Status:
51 --   Internal Row Handler Use Only.
52 --
53 -- {End Of Comments}
54 -- ----------------------------------------------------------------------------
55 Procedure insert_dml
56   (p_rec in out nocopy hxc_rtc_shd.g_rec_type
57   ) is
58 --
59   l_proc  varchar2(72);
60 --
61 Begin
62 
63 
64   if g_debug then
65   	l_proc := g_package||'insert_dml';
66   	hr_utility.set_location('Entering:'||l_proc, 5);
67   end if;
68   p_rec.object_version_number := 1;  -- Initialise the object version
69   --
70   hxc_rtc_shd.g_api_dml := true;  -- Set the api dml status
71   --
72   -- Insert the row into: hxc_retrieval_rule_comps
73   --
74   insert into hxc_retrieval_rule_comps
75       (retrieval_rule_comp_id
76       ,retrieval_rule_id
77       ,status
78       ,object_version_number
79       ,time_recipient_id
80       ,creation_date
81 ,created_by
82 ,last_updated_by
83 ,last_update_date
84 ,last_update_login
85       )
86   Values
87     (p_rec.retrieval_rule_comp_id
88     ,p_rec.retrieval_rule_id
89     ,p_rec.status
90     ,p_rec.object_version_number
91     ,p_rec.time_recipient_id
92      ,sysdate
93  ,fnd_global.user_id
94  ,fnd_global.user_id
95  ,sysdate
96  ,fnd_global.login_id
97     );
98   --
99   hxc_rtc_shd.g_api_dml := false;   -- Unset the api dml status
100   --
101   if g_debug then
102   	hr_utility.set_location(' Leaving:'||l_proc, 10);
103   end if;
104 Exception
105   When hr_api.check_integrity_violated Then
106     -- A check constraint has been violated
107     hxc_rtc_shd.g_api_dml := false;   -- Unset the api dml status
108     hxc_rtc_shd.constraint_error
109       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110   When hr_api.parent_integrity_violated Then
111     -- Parent integrity has been violated
112     hxc_rtc_shd.g_api_dml := false;   -- Unset the api dml status
113     hxc_rtc_shd.constraint_error
114       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115   When hr_api.unique_integrity_violated Then
116     -- Unique integrity has been violated
117     hxc_rtc_shd.g_api_dml := false;   -- Unset the api dml status
118     hxc_rtc_shd.constraint_error
119       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120   When Others Then
121     hxc_rtc_shd.g_api_dml := false;   -- Unset the api dml status
122     Raise;
123 End insert_dml;
124 --
125 -- ----------------------------------------------------------------------------
126 -- |------------------------------< pre_insert >------------------------------|
127 -- ----------------------------------------------------------------------------
128 -- {Start Of Comments}
129 --
130 -- Description:
131 --   This private procedure contains any processing which is required before
132 --   the insert dml. Presently, if the entity has a corresponding primary
133 --   key which is maintained by an associating sequence, the primary key for
134 --   the entity will be populated with the next sequence value in
135 --   preparation for the insert dml.
136 --
137 -- Prerequisites:
138 --   This is an internal procedure which is called from the ins procedure.
139 --
140 -- In Parameters:
141 --   A Pl/Sql record structre.
142 --
143 -- Post Success:
144 --   Processing continues.
145 --
146 -- Post Failure:
147 --   If an error has occurred, an error message and exception will be raised
148 --   but not handled.
149 --
150 -- Developer Implementation Notes:
151 --   Any pre-processing required before the insert dml is issued should be
152 --   coded within this procedure. As stated above, a good example is the
153 --   generation of a primary key number via a corresponding sequence.
154 --   It is important to note that any 3rd party maintenance should be reviewed
155 --   before placing in this procedure.
156 --
157 -- Access Status:
158 --   Internal Row Handler Use Only.
159 --
160 -- {End Of Comments}
161 -- ----------------------------------------------------------------------------
162 Procedure pre_insert
163   (p_rec  in out nocopy hxc_rtc_shd.g_rec_type
164   ) is
165 --
166   l_proc  varchar2(72);
167 --
168   Cursor C_Sel1 is select hxc_retrieval_rule_comps_s.nextval from sys.dual;
169 --
170 Begin
171 
172 
173   if g_debug then
174   	l_proc := g_package||'pre_insert';
175   	hr_utility.set_location('Entering:'||l_proc, 5);
176   end if;
177   --
178   --
179   -- Select the next sequence number
180   --
181   Open C_Sel1;
182   Fetch C_Sel1 Into p_rec.retrieval_rule_comp_id;
183   Close C_Sel1;
184   --
185   if g_debug then
186   	hr_utility.set_location(' Leaving:'||l_proc, 10);
187   end if;
188 End pre_insert;
189 --
190 -- ----------------------------------------------------------------------------
191 -- |-----------------------------< post_insert >------------------------------|
192 -- ----------------------------------------------------------------------------
193 -- {Start Of Comments}
194 --
195 -- Description:
196 --   This private procedure contains any processing which is required after the
197 --   insert dml.
198 --
199 -- Prerequisites:
200 --   This is an internal procedure which is called from the ins procedure.
201 --
202 -- In Parameters:
203 --   A Pl/Sql record structre.
204 --
205 -- Post Success:
206 --   Processing continues.
207 --
208 -- Post Failure:
209 --   If an error has occurred, an error message and exception will be raised
210 --   but not handled.
211 --
212 -- Developer Implementation Notes:
213 --   Any post-processing required after the insert dml is issued should be
214 --   coded within this procedure. It is important to note that any 3rd party
215 --   maintenance should be reviewed before placing in this procedure.
216 --
217 -- Access Status:
218 --   Internal Row Handler Use Only.
219 --
220 -- {End Of Comments}
221 -- ----------------------------------------------------------------------------
222 Procedure post_insert
223   (p_effective_date               in date
224   ,p_rec                          in hxc_rtc_shd.g_rec_type
225   ) is
226 --
227   l_proc  varchar2(72);
228 --
229 Begin
230 
231 
232   if g_debug then
233   	l_proc := g_package||'post_insert';
234   	hr_utility.set_location('Entering:'||l_proc, 5);
235   end if;
236   begin
237     --
238     hxc_rtc_rki.after_insert
239       (p_effective_date              => p_effective_date
240       ,p_retrieval_rule_comp_id
241       => p_rec.retrieval_rule_comp_id
242       ,p_retrieval_rule_id
243       => p_rec.retrieval_rule_id
244       ,p_status
245       => p_rec.status
246       ,p_object_version_number
247       => p_rec.object_version_number
248       ,p_time_recipient_id
249       => p_rec.time_recipient_id
250       );
251     --
252   exception
253     --
254     when hr_api.cannot_find_prog_unit then
255       --
256       hr_api.cannot_find_prog_unit_error
257         (p_module_name => 'HXC_RETRIEVAL_RULE_COMPS'
258         ,p_hook_type   => 'AI');
259       --
260   end;
261   --
262   if g_debug then
263   	hr_utility.set_location(' Leaving:'||l_proc, 10);
264   end if;
265 End post_insert;
266 --
267 -- ----------------------------------------------------------------------------
268 -- |---------------------------------< ins >----------------------------------|
269 -- ----------------------------------------------------------------------------
270 Procedure ins
271   (p_effective_date               in date
272   ,p_rec                          in out nocopy hxc_rtc_shd.g_rec_type
273   ) is
274 --
275   l_proc  varchar2(72);
276 --
277 Begin
278   g_debug := hr_utility.debug_enabled;
279 
280   if g_debug then
281   	l_proc := g_package||'ins';
282   	hr_utility.set_location('Entering:'||l_proc, 5);
283   end if;
284   --
285   -- Call the supporting insert validate operations
286   --
287   hxc_rtc_bus.insert_validate
288      (p_effective_date
289      ,p_rec
290      );
291   --
292   -- Call the supporting pre-insert operation
293   --
294   hxc_rtc_ins.pre_insert(p_rec);
295   --
296   -- Insert the row
297   --
298   hxc_rtc_ins.insert_dml(p_rec);
299   --
300   -- Call the supporting post-insert operation
301   --
302   hxc_rtc_ins.post_insert
303      (p_effective_date
304      ,p_rec
305      );
306   --
307   if g_debug then
308   	hr_utility.set_location('Leaving:'||l_proc, 20);
309   end if;
310 end ins;
311 --
312 -- ----------------------------------------------------------------------------
313 -- |---------------------------------< ins >----------------------------------|
314 -- ----------------------------------------------------------------------------
315 Procedure ins
316   (p_effective_date               in     date
317   ,p_retrieval_rule_id              in     number
318   ,p_status                         in     varchar2
319   ,p_time_recipient_id              in     number
320   ,p_retrieval_rule_comp_id            out nocopy number
321   ,p_object_version_number             out nocopy number
322   ) is
323 --
324   l_rec	  hxc_rtc_shd.g_rec_type;
325   l_proc  varchar2(72);
326 --
327 Begin
328   g_debug := hr_utility.debug_enabled;
329 
330   if g_debug then
331   	l_proc := g_package||'ins';
332   	hr_utility.set_location('Entering:'||l_proc, 5);
333   end if;
334   --
335   -- Call conversion function to turn arguments into the
336   -- p_rec structure.
337   --
338   l_rec :=
339   hxc_rtc_shd.convert_args
340     (null
341     ,p_retrieval_rule_id
342     ,p_status
343     ,null
344     ,p_time_recipient_id
345     );
346   --
347   -- Having converted the arguments into the hxc_rtc_rec
348   -- plsql record structure we call the corresponding record business process.
349   --
350   hxc_rtc_ins.ins
351      (p_effective_date
352      ,l_rec
353      );
354   --
355   -- As the primary key argument(s)
356   -- are specified as an OUT's we must set these values.
357   --
358   p_retrieval_rule_comp_id := l_rec.retrieval_rule_comp_id;
359   p_object_version_number := l_rec.object_version_number;
360   --
361   if g_debug then
362   	hr_utility.set_location(' Leaving:'||l_proc, 10);
363   end if;
364 End ins;
365 --
366 end hxc_rtc_ins;