DBA Data[Home] [Help]
Skip to content

PACKAGE BODY: APPS.PER_WBI_INS

Source


1 Package Body per_wbi_ins as
2 /* $Header: pewbirhi.pkb 115.0 2003/07/03 05:55:25 kavenkat noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33) := '  per_wbi_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_workbench_item_code_i  per_ri_workbench_items.WORKBENCH_ITEM_CODE%Type   default null;
14 --
15 -- ----------------------------------------------------------------------------
16 -- |------------------------< set_base_key_value >----------------------------|
17 -- ----------------------------------------------------------------------------
18 procedure set_base_key_value
19   (p_workbench_item_code  in  Varchar2) 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   per_wbi_ins.g_workbench_item_code_i := p_workbench_item_code;
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 per_wbi_shd.g_rec_type
77   ) is
78 --
79   l_proc  varchar2(72) := g_package||'insert_dml';
80 --
81 Begin
82   hr_utility.set_location('Entering:'||l_proc, 5);
83   p_rec.object_version_number := 1;  -- Initialise the object version
84   --
85   --
86   --
87   -- Insert the row into: per_ri_workbench_items
88   --
89   insert into per_ri_workbench_items
90       (workbench_item_code
91       ,menu_id
92       ,workbench_item_sequence
93       ,workbench_parent_item_code
94       ,workbench_item_creation_date
95       ,workbench_item_type
96       ,object_version_number
97       )
98   Values
99     (p_rec.workbench_item_code
100     ,p_rec.menu_id
101     ,p_rec.workbench_item_sequence
102     ,p_rec.workbench_parent_item_code
103     ,p_rec.workbench_item_creation_date
104     ,p_rec.workbench_item_type
105     ,p_rec.object_version_number
106     );
107   --
108   --
109   --
110   hr_utility.set_location(' Leaving:'||l_proc, 10);
111 Exception
112   When hr_api.check_integrity_violated Then
113     -- A check constraint has been violated
114     --
115     per_wbi_shd.constraint_error
116       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117   When hr_api.parent_integrity_violated Then
118     -- Parent integrity has been violated
119     --
120     per_wbi_shd.constraint_error
121       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
122   When hr_api.unique_integrity_violated Then
123     -- Unique integrity has been violated
124     --
125     per_wbi_shd.constraint_error
126       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
127   When Others Then
128     --
129     Raise;
130 End insert_dml;
131 --
132 -- ----------------------------------------------------------------------------
133 -- |------------------------------< pre_insert >------------------------------|
134 -- ----------------------------------------------------------------------------
135 -- {Start Of Comments}
136 --
137 -- Description:
138 --   This private procedure contains any processing which is required before
139 --   the insert dml. Presently, if the entity has a corresponding primary
140 --   key which is maintained by an associating sequence, the primary key for
141 --   the entity will be populated with the next sequence value in
142 --   preparation for the insert dml.
143 --
144 -- Prerequisites:
145 --   This is an internal procedure which is called from the ins procedure.
146 --
147 -- In Parameters:
148 --   A Pl/Sql record structure.
149 --
150 -- Post Success:
151 --   Processing continues.
152 --
153 -- Post Failure:
154 --   If an error has occurred, an error message and exception will be raised
155 --   but not handled.
156 --
157 -- Developer Implementation Notes:
158 --   Any pre-processing required before the insert dml is issued should be
159 --   coded within this procedure. As stated above, a good example is the
160 --   generation of a primary key number via a corresponding sequence.
161 --   It is important to note that any 3rd party maintenance should be reviewed
162 --   before placing in this procedure.
163 --
164 -- Access Status:
165 --   Internal Row Handler Use Only.
166 --
167 -- {End Of Comments}
168 -- ----------------------------------------------------------------------------
169 Procedure pre_insert
170   (p_rec  in out nocopy per_wbi_shd.g_rec_type
171   ) is
172 
173 --
174   Cursor C_Sel2 is
175     Select null
176       from per_ri_workbench_items
177      where workbench_item_code =
178              per_wbi_ins.g_workbench_item_code_i;
179 --
180   l_proc   varchar2(72) := g_package||'pre_insert';
181   l_exists varchar2(1);
182 --
183 Begin
184   hr_utility.set_location('Entering:'||l_proc, 5);
185   --
186   If (per_wbi_ins.g_workbench_item_code_i is not null) Then
187     --
188     -- Verify registered primary key values not already in use
189     --
190     Open C_Sel2;
191     Fetch C_Sel2 into l_exists;
192     If C_Sel2%found Then
193        Close C_Sel2;
194        --
195        -- The primary key values are already in use.
196        --
197        fnd_message.set_name('PER','PER_289391_KEY_ALREADY_USED');
198        fnd_message.set_token('TABLE_NAME','per_ri_workbench_items');
199        fnd_message.raise_error;
200     End If;
201     Close C_Sel2;
202     --
203     -- Use registered key values and clear globals
204     --
205     p_rec.workbench_item_code :=
206       per_wbi_ins.g_workbench_item_code_i;
207     per_wbi_ins.g_workbench_item_code_i := null;
208   Else
209     --
210     -- No registerd key values, so raise error
211     --
212     hr_utility.set_message(801, 'HR_7207_API_MANDATORY_ARG');
213     hr_utility.set_message_token('API_NAME', g_package);
214     hr_utility.set_message_token('ARGUMENT', 'workbench_item_code');
215     hr_utility.raise_error;
216 
217   End If;
218   --
219   hr_utility.set_location(' Leaving:'||l_proc, 10);
220 End pre_insert;
221 --
222 -- ----------------------------------------------------------------------------
223 -- |-----------------------------< post_insert >------------------------------|
224 -- ----------------------------------------------------------------------------
225 -- {Start Of Comments}
226 --
227 -- Description:
228 --   This private procedure contains any processing which is required after
229 --   the insert dml.
230 --
231 -- Prerequisites:
232 --   This is an internal procedure which is called from the ins procedure.
233 --
234 -- In Parameters:
235 --   A Pl/Sql record structre.
236 --
237 -- Post Success:
238 --   Processing continues.
239 --
240 -- Post Failure:
241 --   If an error has occurred, an error message and exception will be raised
242 --   but not handled.
243 --
244 -- Developer Implementation Notes:
245 --   Any post-processing required after the insert dml is issued should be
246 --   coded within this procedure. It is important to note that any 3rd party
247 --   maintenance should be reviewed before placing in this procedure.
248 --
249 -- Access Status:
250 --   Internal Row Handler Use Only.
251 --
252 -- {End Of Comments}
253 -- ----------------------------------------------------------------------------
254 Procedure post_insert
255   (p_effective_date               in date
256   ,p_rec                          in per_wbi_shd.g_rec_type
257   ) is
258 --
259   l_proc  varchar2(72) := g_package||'post_insert';
260 --
261 Begin
262   hr_utility.set_location('Entering:'||l_proc, 5);
263   begin
264     --
265     per_wbi_rki.after_insert
266       (p_effective_date                => p_effective_date
267       ,p_workbench_item_code           => p_rec.workbench_item_code
268       ,p_menu_id                       => p_rec.menu_id
269       ,p_workbench_item_sequence       => p_rec.workbench_item_sequence
270       ,p_workbench_parent_item_code    => p_rec.workbench_parent_item_code
271       ,p_workbench_item_creation_date  => p_rec.workbench_item_creation_date
272       ,p_workbench_item_type           => p_rec.workbench_item_type
273       ,p_object_version_number         => p_rec.object_version_number
274       );
275     --
276   exception
277     --
278     when hr_api.cannot_find_prog_unit then
279       --
280       hr_api.cannot_find_prog_unit_error
281         (p_module_name => 'PER_RI_WORKBENCH_ITEMS'
282         ,p_hook_type   => 'AI');
283       --
284   end;
285   --
286   hr_utility.set_location(' Leaving:'||l_proc, 10);
287 End post_insert;
288 --
289 -- ----------------------------------------------------------------------------
290 -- |---------------------------------< ins >----------------------------------|
291 -- ----------------------------------------------------------------------------
292 Procedure ins
293   (p_effective_date               in date
294   ,p_rec                          in out nocopy per_wbi_shd.g_rec_type
295   ) is
296 --
297   l_proc  varchar2(72) := g_package||'ins';
298 --
299 Begin
300   hr_utility.set_location('Entering:'||l_proc, 5);
301   --
302   -- Call the supporting insert validate operations
303   --
304   per_wbi_bus.insert_validate
305      (p_effective_date
306      ,p_rec
307      );
308   --
309   -- Call to raise any errors on multi-message list
310   hr_multi_message.end_validation_set;
311   --
312   -- Call the supporting pre-insert operation
313   --
314   per_wbi_ins.pre_insert(p_rec);
315   --
316   -- Insert the row
317   --
318   per_wbi_ins.insert_dml(p_rec);
319   --
320   -- Call the supporting post-insert operation
321   --
322   per_wbi_ins.post_insert
323      (p_effective_date
324      ,p_rec
325      );
326   --
327   -- Call to raise any errors on multi-message list
328   hr_multi_message.end_validation_set;
329   --
330   hr_utility.set_location('Leaving:'||l_proc, 20);
331 end ins;
332 --
333 -- ----------------------------------------------------------------------------
334 -- |---------------------------------< ins >----------------------------------|
335 -- ----------------------------------------------------------------------------
336 Procedure ins
337   (p_effective_date                 in  date
338   ,p_menu_id                        in  number
339   ,p_workbench_item_sequence        in  number
340   ,p_workbench_parent_item_code     in  varchar2
341   ,p_workbench_item_creation_date   in  date     default null
342   ,p_workbench_item_type            in  varchar2 default null
343   ,p_workbench_item_code            out nocopy varchar2
344   ,p_object_version_number          out nocopy number
345   ) is
346 --
347   l_rec   per_wbi_shd.g_rec_type;
348   l_proc  varchar2(72) := g_package||'ins';
349 --
350 Begin
351   hr_utility.set_location('Entering:'||l_proc, 5);
352   --
353   -- Call conversion function to turn arguments into the
354   -- p_rec structure.
355   --
356   l_rec :=
357   per_wbi_shd.convert_args
358     (null
359     ,p_menu_id
360     ,p_workbench_item_sequence
361     ,p_workbench_parent_item_code
362     ,p_workbench_item_creation_date
363     ,p_workbench_item_type
364     ,null
365     );
366   --
367   -- Having converted the arguments into the per_wbi_rec
368   -- plsql record structure we call the corresponding record business process.
369   --
370   per_wbi_ins.ins
371      (p_effective_date
372      ,l_rec
373      );
374   --
375   -- As the primary key argument(s)
376   -- are specified as an OUT's we must set these values.
377   --
378   p_workbench_item_code := l_rec.workbench_item_code;
379   p_object_version_number := l_rec.object_version_number;
380   --
381   hr_utility.set_location(' Leaving:'||l_proc, 10);
382 End ins;
383 --
384 end per_wbi_ins;