DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_RTL_INS

Source


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