DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RTL_INS

Source


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