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