DBA Data[Home] [Help]

PACKAGE BODY: APPS.PQH_TTL_INS

Source


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