DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_CTL_INS

Source


1 Package Body pqh_ctl_ins as
2 /* $Header: pqctlrhi.pkb 120.2 2011/04/28 09:40:38 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pqh_ctl_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_ctl_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_TRANSACTION_CATEGORIES_TL',
61     p_ref_entity=>'PQH_TRANSACTION_CATEGORIES',
62     p_ref_column_name=>'TRANSACTION_CATEGORY_ID',
63     p_ref_col_value_number=>p_rec.transaction_category_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_transaction_categories_tl
72   --
73   insert into pqh_transaction_categories_tl
74   (	transaction_category_id,
75 	name,
76 	language,
77 	source_lang
78   )
79   Values
80   (	p_rec.transaction_category_id,
81 	p_rec.name,
82 	p_rec.language,
83 	p_rec.source_lang
84   );
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     pqh_ctl_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     pqh_ctl_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     pqh_ctl_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 pqh_ctl_shd.g_rec_type,
143                      p_transaction_category_id in number) is
144 --
145   l_proc  varchar2(72) := g_package||'pre_insert';
146 --
147 --
148 --
149 Begin
150   hr_utility.set_location('Entering:'||l_proc, 5);
151   --
152   --
153   p_rec.transaction_category_id := p_transaction_category_id;
154   --
155   hr_utility.set_location(' Leaving:'||l_proc, 10);
156 End pre_insert;
157 --
158 -- ----------------------------------------------------------------------------
159 -- |-----------------------------< post_insert >------------------------------|
160 -- ----------------------------------------------------------------------------
161 -- {Start Of Comments}
162 --
163 -- Description:
164 --   This private procedure contains any processing which is required after the
165 --   insert dml.
166 --
167 -- Prerequisites:
168 --   This is an internal procedure which is called from the ins procedure.
169 --
170 -- In Parameters:
171 --   A Pl/Sql record structre.
172 --
173 -- Post Success:
174 --   Processing continues.
175 --
176 -- Post Failure:
177 --   If an error has occurred, an error message and exception will be raised
178 --   but not handled.
179 --
180 -- Developer Implementation Notes:
181 --   Any post-processing required after the insert dml is issued should be
182 --   coded within this procedure. It is important to note that any 3rd party
183 --   maintenance should be reviewed before placing in this procedure.
184 --
185 -- Access Status:
186 --   Internal Row Handler Use Only.
187 --
188 -- {End Of Comments}
189 -- ----------------------------------------------------------------------------
190 Procedure post_insert(p_rec in pqh_ctl_shd.g_rec_type) is
191 --
192   l_proc  varchar2(72) := g_package||'post_insert';
193 --
194 Begin
195   hr_utility.set_location('Entering:'||l_proc, 5);
196 --
197   --
198   -- Start of API User Hook for post_insert.
199   --
200   begin
201     --
202     pqh_ctl_rki.after_insert
203       (
204   p_transaction_category_id       =>p_rec.transaction_category_id
205  ,p_name                          =>p_rec.name
206  ,p_language                      =>p_rec.language
207  ,p_source_lang                   =>p_rec.source_lang
208       );
209     --
210   exception
211     --
212     when hr_api.cannot_find_prog_unit then
213       --
214       hr_api.cannot_find_prog_unit_error
215         (p_module_name => 'pqh_transaction_categories_tl'
216         ,p_hook_type   => 'AI');
217       --
218   end;
219   --
220   -- End of API User Hook for post_insert.
221   --
222   --
223   hr_utility.set_location(' Leaving:'||l_proc, 10);
224 End post_insert;
225 --
226 -- ----------------------------------------------------------------------------
227 -- |---------------------------------< ins >----------------------------------|
228 -- ----------------------------------------------------------------------------
229 Procedure ins
230   (
231   p_rec        in out nocopy pqh_ctl_shd.g_rec_type,
232   p_transaction_category_id in number
233   ) is
234 --
235   l_proc  varchar2(72) := g_package||'ins';
236 --
237 Begin
238   hr_utility.set_location('Entering:'||l_proc, 5);
239   --
240   -- Call the supporting insert validate operations
241   --
242   pqh_ctl_bus.insert_validate(p_rec);
243   --
244   -- Call the supporting pre-insert operation
245   --
246   pre_insert(p_rec                     => p_rec,
247              p_transaction_category_id => p_transaction_category_id);
248   --
249   -- Insert the row
250   --
251   insert_dml(p_rec);
252   --
253   -- Call the supporting post-insert operation
254   --
255   post_insert(p_rec);
256 end ins;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |---------------------------------< ins >----------------------------------|
260 -- ----------------------------------------------------------------------------
261 Procedure ins
262   (
263   p_transaction_category_id      in number,
264   p_name                         in varchar2,
265   p_language                     in varchar2,
266   p_source_lang                  in varchar2
267   ) is
268 --
269   l_rec	  pqh_ctl_shd.g_rec_type;
270   l_proc  varchar2(72) := g_package||'ins';
271 --
272 Begin
273   hr_utility.set_location('Entering:'||l_proc, 5);
274   --
275   -- Call conversion function to turn arguments into the
276   -- p_rec structure.
277   --
278   l_rec :=
279   pqh_ctl_shd.convert_args
280   (
281   null,
282   p_name,
283   p_language,
284   p_source_lang
285   );
286   --
287   -- Having converted the arguments into the pqh_ctl_rec
288   -- plsql record structure we call the corresponding record business process.
289   --
290   ins(p_rec                      => l_rec,
291       p_transaction_category_id  => p_transaction_category_id);
292   --
293   --
294   hr_utility.set_location(' Leaving:'||l_proc, 10);
295 End ins;
296 --
297 -- ----------------------------------------------------------------------------
298 -- |------------------------------< ins_tl >----------------------------------|
299 -- ----------------------------------------------------------------------------
300 --
301 Procedure ins_tl ( p_transaction_category_id    in number,
302                    p_language_code              in varchar2,
303                    p_name                       in varchar2 ) is
304 --
305 cursor csr_ins_langs is
306   select l.language_code
307   from fnd_languages l
308   where l.installed_flag in ('I','B')
309   and not exists (select null
310                   from pqh_transaction_categories_tl ctl
311                   where ctl.transaction_category_id = p_transaction_category_id
312                   and ctl.language         = l.language_code );
313 --
314   l_proc  varchar2(72) := g_package||'ins_tl';
315 --
316 begin
317   --
318   hr_utility.set_location(' Entering:'||l_proc, 10);
319   --
320   for l_lang in csr_ins_langs loop
321 
322     ins(p_transaction_category_id => p_transaction_category_id,
323         p_name => p_name,
324         p_language => l_lang.language_code,
325         p_source_lang => p_language_code);
326   --
327   end loop;
328   --
329   hr_utility.set_location(' Leaving:'||l_proc, 20);
330   --
331 end ins_tl;
332 --
333 end pqh_ctl_ins;