DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HAS_INS

Source


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