DBA Data[Home] [Help]

PACKAGE BODY: APPS.HXC_DTL_INS

Source


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