DBA Data[Home] [Help]

PACKAGE BODY: APPS.HR_DTT_INS

Source


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