DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_HRT_INS

Source


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