DBA Data[Home] [Help]

PACKAGE BODY: APPS.PER_RVR_INS

Source


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