1 Package Body hr_wpt_ins as
2 /* $Header: hrwptrhi.pkb 120.1 2011/04/28 10:18:56 sidsaxen ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hr_wpt_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 set and unset the g_api_dml status as required (as we are about to
21 -- perform dml).
22 -- 3) To insert the row into the schema.
23 -- 4) To trap any constraint violations that may have occurred.
24 -- 5) To raise any other errors.
25 --
26 -- Prerequisites:
27 -- This is an internal private procedure which must be called from the ins
28 -- procedure and must have all mandatory attributes set (except the
29 -- object_version_number which is initialised within this procedure).
30 --
31 -- In Parameters:
32 -- A Pl/Sql record structre.
33 --
34 -- Post Success:
35 -- The specified row will be inserted into the schema.
36 --
37 -- Post Failure:
38 -- On the insert dml failure it is important to note that we always reset the
39 -- g_api_dml status to false.
40 -- If a check, unique or parent integrity constraint violation is raised the
41 -- constraint_error procedure will be called.
42 -- If any other error is reported, the error will be raised after the
43 -- g_api_dml status is reset.
44 --
45 -- Developer Implementation Notes:
46 -- None.
47 --
48 -- Access Status:
49 -- Internal Row Handler Use Only.
50 --
51 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml
54 (p_rec in out nocopy hr_wpt_shd.g_rec_type
55 ) is
56 --
57 l_proc varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60 hr_utility.set_location('Entering:'||l_proc, 5);
61 --
62 --
63 --
64 --
65 -- Insert the row into: hr_window_properties_tl
66 --
67
68 --
69 -- Added the following code as a part of Zero Downtime Patching Project.
70 -- Code Starts Here.
71 --
72
73 BEGIN
74 PER_RIC_PKG.chk_integrity (
75 p_entity_name => 'HR_WINDOW_PROPERTIES_TL',
76 p_ref_entity => 'HR_WINDOW_PROPERTIES_B',
77 p_ref_column_name => 'WINDOW_PROPERTY_ID',
78 p_ref_col_value_number => p_rec.window_property_id ,
79 p_ref_col_value_varchar => NULL,
80 p_ref_col_value_date => NULL,
81 p_ref_type => 'INS');
82
83 END;
84 --
85 -- Code Ends Here.
86 --
87 insert into hr_window_properties_tl
88 (window_property_id
89 ,language
90 ,source_lang
91 ,title
92 )
93 Values
94 (p_rec.window_property_id
95 ,p_rec.language
96 ,p_rec.source_lang
97 ,p_rec.title
98 );
99 --
100 --
101 --
102 hr_utility.set_location(' Leaving:'||l_proc, 10);
103 Exception
104 When hr_api.check_integrity_violated Then
105 -- A check constraint has been violated
106 --
107 hr_wpt_shd.constraint_error
108 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
109 When hr_api.parent_integrity_violated Then
110 -- Parent integrity has been violated
111 --
112 hr_wpt_shd.constraint_error
113 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
114 When hr_api.unique_integrity_violated Then
115 -- Unique integrity has been violated
116 --
117 hr_wpt_shd.constraint_error
118 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
119 When Others Then
120 --
121 Raise;
122 End insert_dml;
123 --
124 -- ----------------------------------------------------------------------------
125 -- |------------------------------< pre_insert >------------------------------|
126 -- ----------------------------------------------------------------------------
127 -- {Start Of Comments}
128 --
129 -- Description:
130 -- This private procedure contains any processing which is required before
131 -- the insert dml. Presently, if the entity has a corresponding primary
132 -- key which is maintained by an associating sequence, the primary key for
133 -- the entity will be populated with the next sequence value in
134 -- preparation for the insert dml.
135 --
136 -- Prerequisites:
137 -- This is an internal procedure which is called from the ins procedure.
138 --
139 -- In Parameters:
140 -- A Pl/Sql record structre.
141 --
142 -- Post Success:
143 -- Processing continues.
144 --
145 -- Post Failure:
146 -- If an error has occurred, an error message and exception will be raised
147 -- but not handled.
148 --
149 -- Developer Implementation Notes:
150 -- Any pre-processing required before the insert dml is issued should be
151 -- coded within this procedure. As stated above, a good example is the
152 -- generation of a primary key number via a corresponding sequence.
153 -- It is important to note that any 3rd party maintenance should be reviewed
154 -- before placing in this procedure.
155 --
156 -- Access Status:
157 -- Internal Row Handler Use Only.
158 --
159 -- {End Of Comments}
160 -- ----------------------------------------------------------------------------
161 Procedure pre_insert
162 (p_rec in out nocopy hr_wpt_shd.g_rec_type
163 ,p_window_property_id in number
164 ) is
165 --
166 l_proc varchar2(72) := g_package||'pre_insert';
167 --
168 Begin
169 hr_utility.set_location('Entering:'||l_proc, 5);
170 --
171 p_rec.window_property_id := p_window_property_id;
172 --
173 hr_utility.set_location(' Leaving:'||l_proc, 10);
174 End pre_insert;
175 --
176 -- ----------------------------------------------------------------------------
177 -- |-----------------------------< post_insert >------------------------------|
178 -- ----------------------------------------------------------------------------
179 -- {Start Of Comments}
180 --
181 -- Description:
182 -- This private procedure contains any processing which is required after the
183 -- insert dml.
184 --
185 -- Prerequisites:
186 -- This is an internal procedure which is called from the ins procedure.
187 --
188 -- In Parameters:
189 -- A Pl/Sql record structre.
190 --
191 -- Post Success:
192 -- Processing continues.
193 --
194 -- Post Failure:
195 -- If an error has occurred, an error message and exception will be raised
196 -- but not handled.
197 --
198 -- Developer Implementation Notes:
199 -- Any post-processing required after the insert dml is issued should be
200 -- coded within this procedure. It is important to note that any 3rd party
201 -- maintenance should be reviewed before placing in this procedure.
202 --
203 -- Access Status:
204 -- Internal Row Handler Use Only.
205 --
206 -- {End Of Comments}
207 -- ----------------------------------------------------------------------------
208 Procedure post_insert
209 (p_rec in hr_wpt_shd.g_rec_type
210 ) is
211 --
212 l_proc varchar2(72) := g_package||'post_insert';
213 --
214 Begin
215 hr_utility.set_location('Entering:'||l_proc, 5);
216 begin
217 --
218 hr_wpt_rki.after_insert
219 (p_window_property_id
220 => p_rec.window_property_id
221 ,p_language
222 => p_rec.language
223 ,p_source_lang
224 => p_rec.source_lang
225 ,p_title
226 => p_rec.title
227 );
228 --
229 exception
230 --
231 when hr_api.cannot_find_prog_unit then
232 --
233 hr_api.cannot_find_prog_unit_error
234 (p_module_name => 'HR_WINDOW_PROPERTIES_TL'
235 ,p_hook_type => 'AI');
236 --
237 end;
238 --
239 hr_utility.set_location(' Leaving:'||l_proc, 10);
240 End post_insert;
241 --
242 -- ----------------------------------------------------------------------------
243 -- |---------------------------------< ins >----------------------------------|
244 -- ----------------------------------------------------------------------------
245 Procedure ins
246 (p_rec in out nocopy hr_wpt_shd.g_rec_type
247 ,p_window_property_id in number
248 ) is
249 --
250 l_proc varchar2(72) := g_package||'ins';
251 --
252 Begin
253 hr_utility.set_location('Entering:'||l_proc, 5);
254 --
255 -- Call the supporting insert validate operations
256 --
257 hr_wpt_bus.insert_validate
258 (p_rec
259 );
260 --
261 -- Call the supporting pre-insert operation
262 --
263 hr_wpt_ins.pre_insert
264 (p_rec => p_rec
265 ,p_window_property_id => p_window_property_id
266 );
267 --
268 -- Insert the row
269 --
270 hr_wpt_ins.insert_dml(p_rec);
271 --
272 -- Call the supporting post-insert operation
273 --
274 hr_wpt_ins.post_insert
275 (p_rec
276 );
277 --
278 hr_utility.set_location('Leaving:'||l_proc, 20);
279 end ins;
280 --
281 -- ----------------------------------------------------------------------------
282 -- |---------------------------------< ins >----------------------------------|
283 -- ----------------------------------------------------------------------------
284 Procedure ins
285 (p_window_property_id in number
286 ,p_language in varchar2
287 ,p_source_lang in varchar2
288 ,p_title in varchar2
289 ) is
290 --
291 l_rec hr_wpt_shd.g_rec_type;
292 l_proc varchar2(72) := g_package||'ins';
293 --
294 Begin
295 hr_utility.set_location('Entering:'||l_proc, 5);
296 --
297 -- Call conversion function to turn arguments into the
298 -- p_rec structure.
299 --
300 l_rec :=
301 hr_wpt_shd.convert_args
302 (null
303 ,p_language
304 ,p_source_lang
305 ,p_title
306 );
307 --
308 -- Having converted the arguments into the hr_wpt_rec
309 -- plsql record structure we call the corresponding record business process.
310 --
311 hr_wpt_ins.ins
312 (p_rec => l_rec
313 ,p_window_property_id => p_window_property_id
314 );
315 --
316 -- As the primary key argument(s)
317 -- are specified as an OUT's we must set these values.
318 --
319 --
320 --
321 hr_utility.set_location(' Leaving:'||l_proc, 10);
322 End ins;
323 --
324 -- ----------------------------------------------------------------------------
325 -- |------------------------------< ins_tl >----------------------------------|
326 -- ----------------------------------------------------------------------------
327 Procedure ins_tl
328 (p_language_code in varchar2
329 ,p_window_property_id in number
330 ,p_title in varchar2 default null
331 ) is
332 --
333 -- Cursor to obtain the list of base and installed languages
334 --
335 cursor csr_ins_langs is
336 select l.language_code
337 from fnd_languages l
338 where l.installed_flag in ('I','B')
339 and not exists (select null
340 from hr_window_properties_tl wpt
341 where wpt.window_property_id = p_window_property_id
342 and wpt.language = l.language_code);
343 --
344 l_proc varchar2(72) := g_package || 'ins_tl';
345 --
346 Begin
347 hr_utility.set_location('Entering:'||l_proc,10);
348 --
349 -- Insert a row for the base language and every installed language.
350 --
351 for l_lang in csr_ins_langs loop
352 hr_wpt_ins.ins
353 (p_window_property_id => p_window_property_id
354 ,p_language => l_lang.language_code
355 ,p_source_lang => p_language_code
356 ,p_title => p_title
357 );
358 end loop;
359 --
360 hr_utility.set_location('Leaving:'||l_proc,20);
361 End ins_tl;
362 --
363 end hr_wpt_ins;