DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_ATL_INS

Source


1 Package Body pqh_atl_ins as
2 /* $Header: pqatlrhi.pkb 120.2 2006/05/23 15:58:59 srajakum ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_atl_ins.';  -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
14 --
15 -- Description:
16 --   This procedure controls the actual dml insert logic. The processing of
17 --   this procedure are as follows:
18 --   1) Initialise the object_version_number to 1 if the object_version_number
19 --      is defined as an attribute for this entity.
20 --   2) To insert the row into the schema.
21 --   3) To trap any constraint violations that may have occurred.
22 --   4) To raise any other errors.
23 --
24 -- Prerequisites:
25 --   This is an internal private procedure which must be called from the ins
26 --   procedure and must have all mandatory attributes set (except the
27 --   object_version_number which is initialised within this procedure).
28 --
29 -- In Parameters:
30 --   A Pl/Sql record structre.
31 --
32 -- Post Success:
33 --   The specified row will be inserted into the schema.
34 --
35 -- Post Failure:
36 --   If a check, unique or parent integrity constraint violation is raised the
37 --   constraint_error procedure will be called.
38 --
39 -- Developer Implementation Notes:
40 --   None.
41 --
42 -- Access Status:
43 --   Internal Row Handler Use Only.
44 --
45 -- {End Of Comments}
46 -- ----------------------------------------------------------------------------
47 Procedure insert_dml(p_rec in out nocopy pqh_atl_shd.g_rec_type) is
48 --
49   l_proc  varchar2(72) := g_package||'insert_dml';
50 --
51 Begin
52   hr_utility.set_location('Entering:'||l_proc, 5);
53   --
54   --
55   --
56   -- Insert the row into: pqh_attributes_tl
57   --
58   insert into pqh_attributes_tl
59   (	attribute_id,
60 	attribute_name,
61 	language,
62 	source_lang
63   )
64   Values
65   (	p_rec.attribute_id,
66 	p_rec.attribute_name,
67 	p_rec.language,
68 	p_rec.source_lang
69   );
70   --
71   --
72   hr_utility.set_location(' Leaving:'||l_proc, 10);
73 Exception
74   When hr_api.check_integrity_violated Then
75     -- A check constraint has been violated
76     pqh_atl_shd.constraint_error
77       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
78   When hr_api.parent_integrity_violated Then
79     -- Parent integrity has been violated
80     pqh_atl_shd.constraint_error
81       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
82   When hr_api.unique_integrity_violated Then
83     -- Unique integrity has been violated
84     pqh_atl_shd.constraint_error
85       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
86   When Others Then
87     Raise;
88 End insert_dml;
89 --
90 -- ----------------------------------------------------------------------------
91 -- |------------------------------< pre_insert >------------------------------|
92 -- ----------------------------------------------------------------------------
93 -- {Start Of Comments}
94 --
95 -- Description:
96 --   This private procedure contains any processing which is required before
97 --   the insert dml. Presently, if the entity has a corresponding primary
98 --   key which is maintained by an associating sequence, the primary key for
99 --   the entity will be populated with the next sequence value in
100 --   preparation for the insert dml.
101 --
102 -- Prerequisites:
103 --   This is an internal procedure which is called from the ins procedure.
104 --
105 -- In Parameters:
106 --   A Pl/Sql record structre.
107 --
108 -- Post Success:
109 --   Processing continues.
110 --
111 -- Post Failure:
112 --   If an error has occurred, an error message and exception will be raised
113 --   but not handled.
114 --
115 -- Developer Implementation Notes:
116 --   Any pre-processing required before the insert dml is issued should be
117 --   coded within this procedure. As stated above, a good example is the
118 --   generation of a primary key number via a corresponding sequence.
119 --   It is important to note that any 3rd party maintenance should be reviewed
120 --   before placing in this procedure.
121 --
122 -- Access Status:
123 --   Internal Row Handler Use Only.
124 --
125 -- {End Of Comments}
126 -- ----------------------------------------------------------------------------
127 Procedure pre_insert(p_rec          in out nocopy pqh_atl_shd.g_rec_type,
128                      p_attribute_id in     number) is
129 --
130   l_proc  varchar2(72) := g_package||'pre_insert';
131 --
132 --
133 --
134 Begin
135   hr_utility.set_location('Entering:'||l_proc, 5);
136   --
137   --
138   p_rec.attribute_id := p_attribute_id;
139   --
140   hr_utility.set_location(' Leaving:'||l_proc, 10);
141 End pre_insert;
142 --
143 -- ----------------------------------------------------------------------------
144 -- |-----------------------------< post_insert >------------------------------|
145 -- ----------------------------------------------------------------------------
146 -- {Start Of Comments}
147 --
148 -- Description:
149 --   This private procedure contains any processing which is required after the
150 --   insert dml.
151 --
152 -- Prerequisites:
153 --   This is an internal procedure which is called from the ins procedure.
154 --
155 -- In Parameters:
156 --   A Pl/Sql record structre.
157 --
158 -- Post Success:
159 --   Processing continues.
160 --
161 -- Post Failure:
162 --   If an error has occurred, an error message and exception will be raised
163 --   but not handled.
164 --
165 -- Developer Implementation Notes:
166 --   Any post-processing required after the insert dml is issued should be
167 --   coded within this procedure. It is important to note that any 3rd party
168 --   maintenance should be reviewed before placing in this procedure.
169 --
170 -- Access Status:
171 --   Internal Row Handler Use Only.
172 --
173 -- {End Of Comments}
174 -- ----------------------------------------------------------------------------
175 Procedure post_insert(p_rec in pqh_atl_shd.g_rec_type) is
176 --
177   l_proc  varchar2(72) := g_package||'post_insert';
178 --
179 Begin
180   hr_utility.set_location('Entering:'||l_proc, 5);
181 --
182   --
183   -- Start of API User Hook for post_insert.
184   --
185   begin
186     --
187     pqh_atl_rki.after_insert
188       (
189   p_attribute_id                  =>p_rec.attribute_id
190  ,p_attribute_name                =>p_rec.attribute_name
191  ,p_language                      =>p_rec.language
192  ,p_source_lang                   =>p_rec.source_lang
193       );
194     --
195   exception
196     --
197     when hr_api.cannot_find_prog_unit then
198       --
199       hr_api.cannot_find_prog_unit_error
200         (p_module_name => 'pqh_attributes_tl'
201         ,p_hook_type   => 'AI');
202       --
203   end;
204   --
205   -- End of API User Hook for post_insert.
206   --
207   --
208   hr_utility.set_location(' Leaving:'||l_proc, 10);
209 End post_insert;
210 --
211 -- ----------------------------------------------------------------------------
212 -- |---------------------------------< ins >----------------------------------|
213 -- ----------------------------------------------------------------------------
214 Procedure ins
215   (
216   p_rec        in out nocopy pqh_atl_shd.g_rec_type,
217   p_attribute_id  in  number
218   ) is
219 --
220   l_proc  varchar2(72) := g_package||'ins';
221 --
222 Begin
223   hr_utility.set_location('Entering:'||l_proc, 5);
224   --
225   -- Call the supporting insert validate operations
226   --
227   pqh_atl_bus.insert_validate(p_rec);
228   --
229   -- Call the supporting pre-insert operation
230   --
231   pre_insert(p_rec           =>  p_rec,
232              p_attribute_id  => p_attribute_id);
233   --
234   -- Insert the row
235   --
236   insert_dml(p_rec);
237   --
238   -- Call the supporting post-insert operation
239   --
240   post_insert(p_rec);
241 end ins;
242 --
243 -- ----------------------------------------------------------------------------
244 -- |---------------------------------< ins >----------------------------------|
245 -- ----------------------------------------------------------------------------
246 Procedure ins
247   (
248   p_attribute_id                 in number,
249   p_attribute_name               in varchar2,
250   p_language                     in varchar2,
251   p_source_lang                  in varchar2
252   ) is
253 --
254   l_rec	  pqh_atl_shd.g_rec_type;
255   l_proc  varchar2(72) := g_package||'ins';
256 --
257 Begin
258   hr_utility.set_location('Entering:'||l_proc, 5);
259   --
260   -- Call conversion function to turn arguments into the
261   -- p_rec structure.
262   --
263   l_rec :=
264   pqh_atl_shd.convert_args
265   (
266   null,
267   p_attribute_name,
268   p_language,
269   p_source_lang
270   );
271   --
272   -- Having converted the arguments into the pqh_atl_rec
273   -- plsql record structure we call the corresponding record business process.
274   --
275   ins(p_rec          => l_rec,
276       p_attribute_id => p_attribute_id);
277   --
278   --
279   hr_utility.set_location(' Leaving:'||l_proc, 10);
280 End ins;
281 --
282 -- ----------------------------------------------------------------------------
283 -- |------------------------------< ins_tl >----------------------------------|
284 -- ----------------------------------------------------------------------------
285 --
286 Procedure ins_tl ( p_attribute_id    in number,
287                    p_language_code   in varchar2,
288                    p_attribute_name  in varchar2 ) is
289 --
290 cursor csr_ins_langs is
291   select l.language_code
292   from fnd_languages l
293   where l.installed_flag in ('I','B')
294   and not exists (select null
295                   from pqh_attributes_tl atl
296                   where atl.attribute_id = p_attribute_id
297                     and atl.language     = l.language_code );
298 --
299   l_proc  varchar2(72) := g_package||'ins_tl';
300 --
301 begin
302   --
303   hr_utility.set_location(' Entering:'||l_proc, 10);
304   --
305   for l_lang in csr_ins_langs loop
306 
307     ins(p_attribute_id     => p_attribute_id,
308         p_attribute_name   => p_attribute_name,
309         p_language         => l_lang.language_code,
310         p_source_lang      => p_language_code);
311   --
312   end loop;
313   --
314   hr_utility.set_location(' Leaving:'||l_proc, 20);
315   --
316 end ins_tl;
317 --
318 end pqh_atl_ins;