DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_DRU_INS

Source


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