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