DBA Data[Home] [Help]

PACKAGE BODY: APPS.BEN_PUM_INS

Source


1 Package Body ben_pum_ins as
2 /* $Header: bepumrhi.pkb 120.0 2005/05/28 11:26:51 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  ben_pum_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(p_rec in out nocopy ben_pum_shd.g_rec_type) is
54 --
55   l_proc  varchar2(72) := g_package||'insert_dml';
56 --
57 Begin
58   hr_utility.set_location('Entering:'||l_proc, 5);
59   p_rec.object_version_number := 1;  -- Initialise the object version
60   --
61   ben_pum_shd.g_api_dml := true;  -- Set the api dml status
62   --
63   -- Insert the row into: ben_pop_up_messages
64   --
65   insert into ben_pop_up_messages
66   (	pop_up_messages_id,
67 	pop_name,
68 	formula_id,
69 	function_name,
70 	block_name,
71 	field_name,
72 	event_name,
73 	message,
74 	message_type,
75 	business_group_id,
76 	object_version_number,
77 	start_date,
78 	end_date,
79 	no_formula_flag
80   )
81   Values
82   (	p_rec.pop_up_messages_id,
83 	p_rec.pop_name,
84 	p_rec.formula_id,
85 	p_rec.function_name,
86 	p_rec.block_name,
87 	p_rec.field_name,
88 	p_rec.event_name,
89 	p_rec.message,
90 	p_rec.message_type,
91 	p_rec.business_group_id,
92 	p_rec.object_version_number,
93 	p_rec.start_date,
94 	p_rec.end_date,
95 	p_rec.no_formula_flag
96   );
97   --
98   ben_pum_shd.g_api_dml := false;   -- Unset the api dml status
99   --
100   hr_utility.set_location(' Leaving:'||l_proc, 10);
101 Exception
102   When hr_api.check_integrity_violated Then
103     -- A check constraint has been violated
104     ben_pum_shd.g_api_dml := false;   -- Unset the api dml status
105     ben_pum_shd.constraint_error
106       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
107   When hr_api.parent_integrity_violated Then
108     -- Parent integrity has been violated
109     ben_pum_shd.g_api_dml := false;   -- Unset the api dml status
110     ben_pum_shd.constraint_error
111       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
112   When hr_api.unique_integrity_violated Then
113     -- Unique integrity has been violated
114     ben_pum_shd.g_api_dml := false;   -- Unset the api dml status
115     ben_pum_shd.constraint_error
116       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
117   When Others Then
118     ben_pum_shd.g_api_dml := false;   -- Unset the api dml status
119     Raise;
120 End insert_dml;
121 --
122 -- ----------------------------------------------------------------------------
123 -- |------------------------------< pre_insert >------------------------------|
124 -- ----------------------------------------------------------------------------
125 -- {Start Of Comments}
126 --
127 -- Description:
128 --   This private procedure contains any processing which is required before
129 --   the insert dml. Presently, if the entity has a corresponding primary
130 --   key which is maintained by an associating sequence, the primary key for
131 --   the entity will be populated with the next sequence value in
132 --   preparation for the insert dml.
133 --
134 -- Prerequisites:
135 --   This is an internal procedure which is called from the ins procedure.
136 --
137 -- In Parameters:
138 --   A Pl/Sql record structre.
139 --
140 -- Post Success:
141 --   Processing continues.
142 --
143 -- Post Failure:
144 --   If an error has occurred, an error message and exception will be raised
145 --   but not handled.
146 --
147 -- Developer Implementation Notes:
148 --   Any pre-processing required before the insert dml is issued should be
149 --   coded within this procedure. As stated above, a good example is the
150 --   generation of a primary key number via a corresponding sequence.
151 --   It is important to note that any 3rd party maintenance should be reviewed
152 --   before placing in this procedure.
153 --
154 -- Access Status:
155 --   Internal Row Handler Use Only.
156 --
157 -- {End Of Comments}
158 -- ----------------------------------------------------------------------------
159 Procedure pre_insert(p_rec  in out nocopy ben_pum_shd.g_rec_type) is
160 --
161   l_proc  varchar2(72) := g_package||'pre_insert';
162 --
163   Cursor C_Sel1 is select ben_pop_up_messages_s.nextval from sys.dual;
164 --
165 Begin
166   hr_utility.set_location('Entering:'||l_proc, 5);
167   --
168   --
169   -- Select the next sequence number
170   --
171   Open C_Sel1;
172   Fetch C_Sel1 Into p_rec.pop_up_messages_id;
173   Close C_Sel1;
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 the
185 --   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,p_rec in ben_pum_shd.g_rec_type) is
212 --
213   l_proc  varchar2(72) := g_package||'post_insert';
214 --
215 Begin
216   hr_utility.set_location('Entering:'||l_proc, 5);
217 --
218   --
219   -- Start of API User Hook for post_insert.
220   --
221   begin
222     --
223     ben_pum_rki.after_insert
224       (
225   p_pop_up_messages_id            =>p_rec.pop_up_messages_id
226  ,p_pop_name                      =>p_rec.pop_name
227  ,p_formula_id                    =>p_rec.formula_id
228  ,p_function_name                 =>p_rec.function_name
229  ,p_block_name                    =>p_rec.block_name
230  ,p_field_name                    =>p_rec.field_name
231  ,p_event_name                    =>p_rec.event_name
232  ,p_message                       =>p_rec.message
233  ,p_message_type                  =>p_rec.message_type
234  ,p_business_group_id             =>p_rec.business_group_id
235  ,p_object_version_number         =>p_rec.object_version_number
236  ,p_start_date                    =>p_rec.start_date
237  ,p_end_date                      =>p_rec.end_date
238  ,p_no_formula_flag               =>p_rec.no_formula_flag
239  ,p_effective_date                =>p_effective_date
240       );
241     --
242   exception
243     --
244     when hr_api.cannot_find_prog_unit then
245       --
246       hr_api.cannot_find_prog_unit_error
247         (p_module_name => 'ben_pop_up_messages'
248         ,p_hook_type   => 'AI');
249       --
250   end;
251   --
252   -- End of API User Hook for post_insert.
253   --
254   --
255   hr_utility.set_location(' Leaving:'||l_proc, 10);
256 End post_insert;
257 --
258 -- ----------------------------------------------------------------------------
259 -- |---------------------------------< ins >----------------------------------|
260 -- ----------------------------------------------------------------------------
261 Procedure ins
262   (
263   p_effective_date in date,
264   p_rec        in out nocopy ben_pum_shd.g_rec_type
265   ) is
266 --
267   l_proc  varchar2(72) := g_package||'ins';
268 --
269 Begin
270   hr_utility.set_location('Entering:'||l_proc, 5);
271   --
272   -- Call the supporting insert validate operations
273   --
274   ben_pum_bus.insert_validate(p_rec
275   ,p_effective_date);
276   --
277   -- Call the supporting pre-insert operation
278   --
279   pre_insert(p_rec);
280   --
281   -- Insert the row
282   --
283   insert_dml(p_rec);
284   --
285   -- Call the supporting post-insert operation
286   --
287   post_insert(
288 p_effective_date,p_rec);
289 end ins;
290 --
291 -- ----------------------------------------------------------------------------
292 -- |---------------------------------< ins >----------------------------------|
293 -- ----------------------------------------------------------------------------
294 Procedure ins
295   (
296   p_effective_date in date,
297   p_pop_up_messages_id           out nocopy number,
298   p_pop_name                     in varchar2         default null,
299   p_formula_id                   in number           default null,
300   p_function_name                in varchar2         default null,
301   p_block_name                   in varchar2         default null,
302   p_field_name                   in varchar2         default null,
303   p_event_name                   in varchar2         default null,
304   p_message                      in varchar2         default null,
305   p_message_type                 in varchar2         default null,
306   p_business_group_id            in number           default null,
307   p_object_version_number        out nocopy number,
308   p_start_date                   in date             default null,
309   p_end_date                     in date             default null,
310   p_no_formula_flag              in varchar2         default null
311   ) is
312 --
313   l_rec	  ben_pum_shd.g_rec_type;
314   l_proc  varchar2(72) := g_package||'ins';
315 --
316 Begin
317   hr_utility.set_location('Entering:'||l_proc, 5);
318   --
319   -- Call conversion function to turn arguments into the
320   -- p_rec structure.
321   --
322   l_rec :=
323   ben_pum_shd.convert_args
324   (
325   null,
326   p_pop_name,
327   p_formula_id,
328   p_function_name,
329   p_block_name,
330   p_field_name,
331   p_event_name,
332   p_message,
333   p_message_type,
334   p_business_group_id,
335   null,
336   p_start_date,
337   p_end_date,
338   p_no_formula_flag
339   );
340   --
341   -- Having converted the arguments into the ben_pum_rec
342   -- plsql record structure we call the corresponding record business process.
343   --
344   ins(
345     p_effective_date,l_rec);
346   --
347   -- As the primary key argument(s)
348   -- are specified as an OUT's we must set these values.
349   --
350   p_pop_up_messages_id := l_rec.pop_up_messages_id;
351   p_object_version_number := l_rec.object_version_number;
352   --
353   hr_utility.set_location(' Leaving:'||l_proc, 10);
354 End ins;
355 --
356 end ben_pum_ins;