DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_RTR_INS

Source


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