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