DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HTS_INS

Source


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