DBA Data[Home] [Help]

PACKAGE BODY: APPS.IRC_VCE_INS

Source


1 Package Body irc_vce_ins as
2 /* $Header: irvcerhi.pkb 120.1 2005/12/13 06:42:58 cnholmes noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  irc_vce_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_vacancy_id_i  number   default null;
14 g_variable_comp_lookup_i  number   default null;
15 --
16 -- ----------------------------------------------------------------------------
17 -- |------------------------------< insert_dml >------------------------------|
18 -- ----------------------------------------------------------------------------
19 -- {Start Of Comments}
20 --
21 -- Description:
22 --   This procedure controls the actual dml insert logic. The processing of
23 --   this procedure are as follows:
24 --   1) Initialise the object_version_number to 1 if the object_version_number
25 --      is defined as an attribute for this entity.
26 --   2) To set and unset the g_api_dml status as required (as we are about to
27 --      perform dml).
28 --   3) To insert the row into the schema.
29 --   4) To trap any constraint violations that may have occurred.
30 --   5) To raise any other errors.
31 --
32 -- Prerequisites:
33 --   This is an internal private procedure which must be called from the ins
34 --   procedure and must have all mandatory attributes set (except the
35 --   object_version_number which is initialised within this procedure).
36 --
37 -- In Parameters:
38 --   A Pl/Sql record structre.
39 --
40 -- Post Success:
41 --   The specified row will be inserted into the schema.
42 --
43 -- Post Failure:
44 --   On the insert dml failure it is important to note that we always reset the
45 --   g_api_dml status to false.
46 --   If a check, unique or parent integrity constraint violation is raised the
47 --   constraint_error procedure will be called.
48 --   If any other error is reported, the error will be raised after the
49 --   g_api_dml status is reset.
50 --
51 -- Developer Implementation Notes:
52 --   None.
53 --
54 -- Access Status:
55 --   Internal Row Handler Use Only.
56 --
57 -- {End Of Comments}
58 -- ----------------------------------------------------------------------------
59 Procedure insert_dml
60   (p_rec in out nocopy irc_vce_shd.g_rec_type
61   ) is
62 --
63   l_proc  varchar2(72) := g_package||'insert_dml';
64 --
65 Begin
66   hr_utility.set_location('Entering:'||l_proc, 5);
67   p_rec.object_version_number := 1;  -- Initialise the object version
68   --
69   irc_vce_shd.g_api_dml := true;  -- Set the api dml status
70   --
71   -- Insert the row into: irc_variable_comp_elements
72   --
73   insert into irc_variable_comp_elements
74       (vacancy_id
75       ,variable_comp_lookup
76       ,object_version_number
77       )
78   Values
79     (p_rec.vacancy_id
80     ,p_rec.variable_comp_lookup
81     ,p_rec.object_version_number
82     );
83   --
84   irc_vce_shd.g_api_dml := false;  -- Unset the api dml status
85   --
86   hr_utility.set_location(' Leaving:'||l_proc, 10);
87 Exception
88   When hr_api.check_integrity_violated Then
89     -- A check constraint has been violated
90     irc_vce_shd.g_api_dml := false;  -- Unset the api dml status
91     --
92     irc_vce_shd.constraint_error
93       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
94   When hr_api.parent_integrity_violated Then
95     -- Parent integrity has been violated
96     irc_vce_shd.g_api_dml := false;  -- Unset the api dml status
97     --
98     irc_vce_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.unique_integrity_violated Then
101     -- Unique integrity has been violated
102     irc_vce_shd.g_api_dml := false;  -- Unset the api dml status
103     --
104     irc_vce_shd.constraint_error
105       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
106   When Others Then
107     --
108     irc_vce_shd.g_api_dml := false;  -- Unset the api dml status
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 structure.
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 irc_vce_shd.g_rec_type
151   ) is
152 --
153   l_proc   varchar2(72) := g_package||'pre_insert';
154   l_exists varchar2(1);
155 --
156 Begin
157   hr_utility.set_location('Entering:'||l_proc, 5);
158   --
159   If (irc_vce_ins.g_vacancy_id_i is not null or
160       irc_vce_ins.g_variable_comp_lookup_i is not null) Then
161     --
162     -- Verify registered primary key values not already in use
163     --
164     --
165     -- Use registered key values and clear globals
166     --
167     p_rec.vacancy_id :=
168       irc_vce_ins.g_vacancy_id_i;
169     irc_vce_ins.g_vacancy_id_i := null;
170     p_rec.variable_comp_lookup :=
171       irc_vce_ins.g_variable_comp_lookup_i;
172     irc_vce_ins.g_variable_comp_lookup_i := null;
173   End If;
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_effective_date               in date
212   ,p_rec                          in irc_vce_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     irc_vce_rki.after_insert
222       (p_effective_date              => p_effective_date
223       ,p_vacancy_id
224       => p_rec.vacancy_id
225       ,p_variable_comp_lookup
226       => p_rec.variable_comp_lookup
227       ,p_object_version_number
228       => p_rec.object_version_number
229       );
230     --
231   exception
232     --
233     when hr_api.cannot_find_prog_unit then
234       --
235       hr_api.cannot_find_prog_unit_error
236         (p_module_name => 'IRC_VARIABLE_COMP_ELEMENTS'
237         ,p_hook_type   => 'AI');
238       --
239   end;
240   --
241   hr_utility.set_location(' Leaving:'||l_proc, 10);
242 End post_insert;
243 --
244 -- ----------------------------------------------------------------------------
245 -- |---------------------------------< ins >----------------------------------|
246 -- ----------------------------------------------------------------------------
247 Procedure ins
248   (p_effective_date               in date
249   ,p_rec                          in out nocopy irc_vce_shd.g_rec_type
250   ) is
251 --
252   l_proc  varchar2(72) := g_package||'ins';
253 --
254 Begin
255   hr_utility.set_location('Entering:'||l_proc, 5);
256   --
257   -- Call the supporting insert validate operations
258   --
259   irc_vce_bus.insert_validate
260      (p_effective_date
261      ,p_rec
262      );
263   -- Call to raise any errors on multi-message list
264   hr_multi_message.end_validation_set;
265   --
266   --
267   -- Call the supporting pre-insert operation
268   --
269   irc_vce_ins.pre_insert(p_rec);
270   --
271   -- Insert the row
272   --
273   irc_vce_ins.insert_dml(p_rec);
274   --
275   -- Call the supporting post-insert operation
276   --
277   irc_vce_ins.post_insert
278      (p_effective_date
279      ,p_rec
280      );
281   --
282   -- Call to raise any errors on multi-message list
283   hr_multi_message.end_validation_set;
284   --
285   hr_utility.set_location('Leaving:'||l_proc, 20);
286 end ins;
287 --
288 -- ----------------------------------------------------------------------------
289 -- |---------------------------------< ins >----------------------------------|
290 -- ----------------------------------------------------------------------------
291 Procedure ins
292   (p_effective_date               in     date
293   ,p_vacancy_id                   in     number
294   ,p_variable_comp_lookup         in     varchar2
295   ,p_object_version_number             out nocopy number
296   ) is
297 --
298   l_rec   irc_vce_shd.g_rec_type;
299   l_proc  varchar2(72) := g_package||'ins';
300 --
301 Begin
302   hr_utility.set_location('Entering:'||l_proc, 5);
303   --
304   -- Call conversion function to turn arguments into the
305   -- p_rec structure.
306   --
307   l_rec :=
308   irc_vce_shd.convert_args
309     (p_object_version_number => p_object_version_number
310     ,p_vacancy_id            => p_vacancy_id
311     ,p_variable_comp_lookup  => p_variable_comp_lookup
312     );
313   --
314   -- Having converted the arguments into the irc_vce_rec
315   -- plsql record structure we call the corresponding record business process.
316   --
317   irc_vce_ins.ins
318      (p_effective_date
319      ,l_rec
320      );
321   --
322   -- As the primary key argument(s)
323   -- are specified as an OUT's we must set these values.
324   --
325   p_object_version_number := l_rec.object_version_number;
326   --
327   hr_utility.set_location(' Leaving:'||l_proc, 10);
328 End ins;
329 --
330 end irc_vce_ins;