DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_STT_INS

Source


1 Package Body per_stt_ins as
2 /* $Header: pesttrhi.pkb 115.4 2002/12/09 14:19:55 eumenyio 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   -- Insert the row into: per_shared_types_tl
58   --
59   insert into per_shared_types_tl
60   (	shared_type_id,
61 	language,
62 	source_lang,
63 	shared_type_name
64   )
65   Values
66   (	p_rec.shared_type_id,
67 	p_rec.language,
68 	p_rec.source_lang,
69 	p_rec.shared_type_name
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     per_stt_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     per_stt_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     per_stt_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 per_stt_shd.g_rec_type,
128                      p_shared_type_id in number ) is
129 --
130   l_proc  varchar2(72) := g_package||'pre_insert';
131 --
132 Begin
133   hr_utility.set_location('Entering:'||l_proc, 5);
134   --
135   p_rec.shared_type_id := p_shared_type_id ;
136   --
137   hr_utility.set_location(' Leaving:'||l_proc, 10);
138 End pre_insert;
139 --
140 -- ----------------------------------------------------------------------------
141 -- |-----------------------------< post_insert >------------------------------|
142 -- ----------------------------------------------------------------------------
143 -- {Start Of Comments}
144 --
145 -- Description:
146 --   This private procedure contains any processing which is required after the
147 --   insert dml.
148 --
149 -- Prerequisites:
150 --   This is an internal procedure which is called from the ins procedure.
151 --
152 -- In Parameters:
153 --   A Pl/Sql record structre.
154 --
155 -- Post Success:
156 --   Processing continues.
157 --
158 -- Post Failure:
159 --   If an error has occurred, an error message and exception will be raised
160 --   but not handled.
161 --
162 -- Developer Implementation Notes:
163 --   Any post-processing required after the insert dml is issued should be
164 --   coded within this procedure. It is important to note that any 3rd party
165 --   maintenance should be reviewed before placing in this procedure.
166 --
167 -- Access Status:
168 --   Internal Row Handler Use Only.
169 --
170 -- {End Of Comments}
171 -- ----------------------------------------------------------------------------
172 Procedure post_insert(p_rec in per_stt_shd.g_rec_type) is
173 --
174   l_proc  varchar2(72) := g_package||'post_insert';
175 --
176 Begin
177   hr_utility.set_location('Entering:'||l_proc, 5);
178 --
179   --
180   -- Start of API User Hook for post_insert.
181   --
182   begin
183     --
184     per_stt_rki.after_insert
185       (
186   p_shared_type_id                =>p_rec.shared_type_id
187  ,p_language                      =>p_rec.language
188  ,p_source_lang                   =>p_rec.source_lang
189  ,p_shared_type_name              =>p_rec.shared_type_name
190       );
191     --
192   exception
193     --
194     when hr_api.cannot_find_prog_unit then
195       --
196       hr_api.cannot_find_prog_unit_error
197         (p_module_name => 'per_shared_types_tl'
198         ,p_hook_type   => 'AI');
199       --
200   end;
201   --
202   -- End of API User Hook for post_insert.
203   --
204   --
205   hr_utility.set_location(' Leaving:'||l_proc, 10);
206 End post_insert;
207 --
208 -- ----------------------------------------------------------------------------
209 -- |---------------------------------< ins >----------------------------------|
210 -- ----------------------------------------------------------------------------
211 Procedure ins
212   (
213   p_rec            in out nocopy per_stt_shd.g_rec_type ,
214   p_shared_type_id in number
215   ) is
216 --
217   l_proc  varchar2(72) := g_package||'ins';
218 --
219 Begin
220   hr_utility.set_location('Entering:'||l_proc, 5);
221   --
222   -- Call the supporting insert validate operations
223   --
224   per_stt_bus.insert_validate(p_rec);
225   --
226   -- Call the supporting pre-insert operation
227   --
228   pre_insert(p_rec            => p_rec,
229              p_shared_type_id => p_shared_type_id );
230   --
231   -- Insert the row
232   --
233   insert_dml(p_rec);
234   --
235   -- Call the supporting post-insert operation
236   --
237   post_insert(p_rec);
238 end ins;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |---------------------------------< ins >----------------------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure ins
244   (
245   p_shared_type_id               in  number,
246   p_language                     in  varchar2,
247   p_source_lang                  in varchar2,
248   p_shared_type_name             in varchar2
249   ) is
250 --
251   l_rec	  per_stt_shd.g_rec_type;
252   l_proc  varchar2(72) := g_package||'ins';
253 --
254 Begin
255   hr_utility.set_location('Entering:'||l_proc, 5);
256   --
257   -- Call conversion function to turn arguments into the
258   -- p_rec structure.
259   --
260   l_rec :=
261   per_stt_shd.convert_args
262   (
263   null,
264   p_language,
265   p_source_lang,
266   p_shared_type_name
267   );
268   --
269   -- Having converted the arguments into the per_stt_rec
270   -- plsql record structure we call the corresponding record business process.
271   --
272   ins(p_rec       => l_rec,
273       p_shared_type_id => p_shared_type_id );
274   --
275   --
276   hr_utility.set_location(' Leaving:'||l_proc, 10);
277 End ins;
278 --
279 procedure ins_tl (
280   p_language_code          in varchar2,
281   p_shared_type_id         in number,
282   p_shared_type_name       in varchar2 ) is
283    cursor csr_ins_langs is
284       select l.language_code
285       from fnd_languages l
286       where l.installed_flag in ('I','B')
287       and not exists ( select null
288                        from per_shared_types_tl stt
289                        where stt.shared_type_id = p_shared_type_id
290                        and stt.language         = l.language_code );
291   l_proc  varchar2(72) := g_package||'ins_tl';
292 begin
293   hr_utility.set_location(' Entering:'||l_proc, 10);
294   for l_lang in csr_ins_langs loop
295     ins
296       (p_shared_type_id    => p_shared_type_id,
297        p_shared_type_name  => p_shared_type_name,
298        p_language          => l_lang.language_code,
299        p_source_lang       => p_language_code) ;
300   end loop;
301   hr_utility.set_location(' Leaving:'||l_proc, 20);
302 end ins_tl;
303 --
304 end per_stt_ins;