DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_ISS_INS

Source


1 Package Body irc_iss_ins as
2 /* $Header: irissrhi.pkb 120.0.12000000.1 2007/03/23 11:28:28 vboggava noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_iss_ins.';  -- Global package name
9 --
10 -- The following global variables are only to be used by
11 -- the set_base_key_value and pre_insert procedures.
12 --
13 g_saved_search_criteria_id_i  number   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_saved_search_criteria_id  in  number) is
20 --
21   l_proc       varchar2(72) := g_package||'set_base_key_value';
22 --
23 Begin
24   hr_utility.set_location('Entering:'||l_proc, 10);
25   --
26   irc_iss_ins.g_saved_search_criteria_id_i := p_saved_search_criteria_id;
27   --
28   hr_utility.set_location(' Leaving:'||l_proc, 20);
29 End set_base_key_value;
30 --
31 --
32 -- ----------------------------------------------------------------------------
33 -- |------------------------------< insert_dml >------------------------------|
34 -- ----------------------------------------------------------------------------
35 -- {Start Of Comments}
36 --
37 -- Description:
38 --   This procedure controls the actual dml insert logic. The processing of
39 --   this procedure are as follows:
40 --   1) Initialise the object_version_number to 1 if the object_version_number
41 --      is defined as an attribute for this entity.
42 --   2) To set and unset the g_api_dml status as required (as we are about to
43 --      perform dml).
44 --   3) To insert the row into the schema.
45 --   4) To trap any constraint violations that may have occurred.
46 --   5) To raise any other errors.
47 --
48 -- Prerequisites:
49 --   This is an internal private procedure which must be called from the ins
50 --   procedure and must have all mandatory attributes set (except the
51 --   object_version_number which is initialised within this procedure).
52 --
53 -- In Parameters:
54 --   A Pl/Sql record structre.
55 --
56 -- Post Success:
57 --   The specified row will be inserted into the schema.
58 --
59 -- Post Failure:
60 --   On the insert dml failure it is important to note that we always reset the
61 --   g_api_dml status to false.
62 --   If a check, unique or parent integrity constraint violation is raised the
63 --   constraint_error procedure will be called.
64 --   If any other error is reported, the error will be raised after the
65 --   g_api_dml status is reset.
66 --
67 -- Developer Implementation Notes:
68 --   None.
69 --
70 -- Access Status:
71 --   Internal Row Handler Use Only.
72 --
73 -- {End Of Comments}
74 -- ----------------------------------------------------------------------------
75 Procedure insert_dml
76   (p_rec in out nocopy irc_iss_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
85   --
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
86   --
87   -- Insert the row into: irc_saved_search_criteria
88   --
89   insert into irc_saved_search_criteria
90       (saved_search_criteria_id
91       ,search_criteria
92       ,vacancy_id
93       ,object_version_number
94       )
95   Values
96     (p_rec.saved_search_criteria_id
97     ,empty_clob()
98     ,p_rec.vacancy_id
99     ,p_rec.object_version_number
100     );
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_iss_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_iss_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_iss_shd.constraint_error
120       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
121   When Others Then
122     --
123     Raise;
124 
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 structure.
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 irc_iss_shd.g_rec_type
166   ) is
167 --
168   Cursor C_Sel1 is select irc_saved_search_criteria_s.nextval from sys.dual;
169 --
170   Cursor C_Sel2 is
171     Select null
172       from irc_saved_search_criteria
173      where saved_search_criteria_id =
174              irc_iss_ins.g_saved_search_criteria_id_i;
175 --
176   l_proc   varchar2(72) := g_package||'pre_insert';
177   l_exists varchar2(1);
178 --
179 Begin
180   hr_utility.set_location('Entering:'||l_proc, 5);
181   --
182   --
183   If (irc_iss_ins.g_saved_search_criteria_id_i is not null) Then
184     --
185     -- Verify registered primary key values not already in use
186     --
187     Open C_Sel2;
188     Fetch C_Sel2 into l_exists;
189     If C_Sel2%found Then
190        Close C_Sel2;
191        --
192        -- The primary key values are already in use.
193        --
194        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
195        fnd_message.set_token('TABLE_NAME','irc_saved_search_criteria');
196        fnd_message.raise_error;
197     End If;
198     Close C_Sel2;
199     --
200     -- Use registered key values and clear globals
201     --
202     p_rec.saved_search_criteria_id :=
203       irc_iss_ins.g_saved_search_criteria_id_i;
204     irc_iss_ins.g_saved_search_criteria_id_i := null;
205   Else
206     --
207     -- No registerd key values, so select the next sequence number
208     --
209     --
210     -- Select the next sequence number
211     --
212     Open C_Sel1;
213     Fetch C_Sel1 Into p_rec.saved_search_criteria_id;
214     Close C_Sel1;
215   End If;
216   --
217   hr_utility.set_location(' Leaving:'||l_proc, 10);
218 End pre_insert;
219 --
220 -- ----------------------------------------------------------------------------
221 -- |-----------------------------< post_insert >------------------------------|
222 -- ----------------------------------------------------------------------------
223 -- {Start Of Comments}
224 --
225 -- Description:
226 --   This private procedure contains any processing which is required after
227 --   the insert dml.
228 --
229 -- Prerequisites:
230 --   This is an internal procedure which is called from the ins procedure.
231 --
232 -- In Parameters:
233 --   A Pl/Sql record structre.
234 --
235 -- Post Success:
236 --   Processing continues.
237 --
238 -- Post Failure:
239 --   If an error has occurred, an error message and exception will be raised
243 --   Any post-processing required after the insert dml is issued should be
240 --   but not handled.
241 --
242 -- Developer Implementation Notes:
244 --   coded within this procedure. It is important to note that any 3rd party
245 --   maintenance should be reviewed before placing in this procedure.
246 --
247 -- Access Status:
248 --   Internal Row Handler Use Only.
249 --
250 -- {End Of Comments}
251 -- ----------------------------------------------------------------------------
252 Procedure post_insert
253   (p_rec                          in irc_iss_shd.g_rec_type
254   ) is
255 --
256   l_proc  varchar2(72) := g_package||'post_insert';
257 --
258 Begin
259   hr_utility.set_location('Entering:'||l_proc, 5);
260   begin
261 
262    --
263     irc_iss_rki.after_insert
264       (p_saved_search_criteria_id
265       => p_rec.saved_search_criteria_id
266       ,p_vacancy_id
267       => p_rec.vacancy_id
268       ,p_object_version_number
269       => p_rec.object_version_number
270       );
271    --
272   exception
273     --
274     when hr_api.cannot_find_prog_unit then
275       --
276       hr_api.cannot_find_prog_unit_error
277         (p_module_name => 'IRC_SAVED_SEARCH_CRITERIA'
278         ,p_hook_type   => 'AI');
279       --
280   end;
281   --
282   hr_utility.set_location(' Leaving:'||l_proc, 10);
283 
284 End post_insert;
285 --
286 -- ----------------------------------------------------------------------------
287 -- |---------------------------------< ins >----------------------------------|
288 -- ----------------------------------------------------------------------------
289 Procedure ins
290   (p_rec                          in out nocopy irc_iss_shd.g_rec_type
291   ) is
292 --
293   l_proc  varchar2(72) := g_package||'ins';
294 --
295 Begin
296   hr_utility.set_location('Entering:'||l_proc, 5);
297   --
298   -- Call the supporting insert validate operations
299   --
300 
301   irc_iss_bus.insert_validate
302      (p_rec
303      );
304   --
305   -- Call to raise any errors on multi-message list
306   hr_multi_message.end_validation_set;
307   --
308   -- Call the supporting pre-insert operation
309   --
310 
311   irc_iss_ins.pre_insert(p_rec);
312   --
313   -- Insert the row
314   --
315 
316   irc_iss_ins.insert_dml(p_rec);
317   --
318   -- Call the supporting post-insert operation
319   --
320 
321   irc_iss_ins.post_insert
322      (p_rec
323      );
324 
325   --
326   -- Call to raise any errors on multi-message list
327   hr_multi_message.end_validation_set;
328   --
329   hr_utility.set_location('Leaving:'||l_proc, 20);
330 end ins;
331 --
332 -- ----------------------------------------------------------------------------
333 -- |---------------------------------< ins >----------------------------------|
334 -- ----------------------------------------------------------------------------
335 Procedure ins
336   (p_search_criteria                in     varchar2 default null
337   ,p_vacancy_id                     in     number   default null
338   ,p_saved_search_criteria_id          out nocopy number
339   ,p_object_version_number             out nocopy number
340   ) is
341 --
342   l_rec   irc_iss_shd.g_rec_type;
343   l_proc  varchar2(72) := g_package||'ins';
344 --
345 Begin
346   hr_utility.set_location('Entering:'||l_proc, 5);
347   --
348   -- Call conversion function to turn arguments into the
349   -- p_rec structure.
350   --
351   l_rec :=
352   irc_iss_shd.convert_args
353     (null
354     ,p_search_criteria
355     ,p_vacancy_id
356     ,null
357     );
358   --
359   -- Having converted the arguments into the irc_iss_rec
360   -- plsql record structure we call the corresponding record business process.
361   --
362   irc_iss_ins.ins
363      (l_rec
364      );
365   --
366   -- As the primary key argument(s)
367   -- are specified as an OUT's we must set these values.
368   --
369   p_saved_search_criteria_id := l_rec.saved_search_criteria_id;
370   p_object_version_number := l_rec.object_version_number;
371   --
372   hr_utility.set_location(' Leaving:'||l_proc, 10);
373 End ins;
374 --
375 end irc_iss_ins;