DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HTR_INS

Source


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