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