DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STT_INS

Source


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