DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_IRT_INS

Source


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