1 Package Body ben_bbp_ins as
2 /* $Header: bebbprhi.pkb 120.0 2005/05/28 00:34:03 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' ben_bbp_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_bbp_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_bbp_shd.g_api_dml := true; -- Set the api dml status
62 --
63 -- Insert the row into: ben_batch_parameter
64 --
65 insert into ben_batch_parameter
66 ( batch_parameter_id,
67 batch_exe_cd,
68 thread_cnt_num,
69 max_err_num,
70 chunk_size,
71 business_group_id,
72 object_version_number
73 )
74 Values
75 ( p_rec.batch_parameter_id,
76 p_rec.batch_exe_cd,
77 p_rec.thread_cnt_num,
78 p_rec.max_err_num,
79 p_rec.chunk_size,
80 p_rec.business_group_id,
81 p_rec.object_version_number
82 );
83 --
84 ben_bbp_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 ben_bbp_shd.g_api_dml := false; -- Unset the api dml status
91 ben_bbp_shd.constraint_error
92 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
93 When hr_api.parent_integrity_violated Then
94 -- Parent integrity has been violated
95 ben_bbp_shd.g_api_dml := false; -- Unset the api dml status
96 ben_bbp_shd.constraint_error
97 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
98 When hr_api.unique_integrity_violated Then
99 -- Unique integrity has been violated
100 ben_bbp_shd.g_api_dml := false; -- Unset the api dml status
101 ben_bbp_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When Others Then
104 ben_bbp_shd.g_api_dml := false; -- Unset the api dml status
105 Raise;
106 End insert_dml;
107 --
108 -- ----------------------------------------------------------------------------
109 -- |------------------------------< pre_insert >------------------------------|
110 -- ----------------------------------------------------------------------------
111 -- {Start Of Comments}
112 --
113 -- Description:
114 -- This private procedure contains any processing which is required before
115 -- the insert dml. Presently, if the entity has a corresponding primary
116 -- key which is maintained by an associating sequence, the primary key for
117 -- the entity will be populated with the next sequence value in
118 -- preparation for the insert dml.
119 --
120 -- Prerequisites:
121 -- This is an internal procedure which is called from the ins procedure.
122 --
123 -- In Parameters:
124 -- A Pl/Sql record structre.
125 --
126 -- Post Success:
127 -- Processing continues.
128 --
129 -- Post Failure:
130 -- If an error has occurred, an error message and exception will be raised
131 -- but not handled.
132 --
133 -- Developer Implementation Notes:
134 -- Any pre-processing required before the insert dml is issued should be
135 -- coded within this procedure. As stated above, a good example is the
136 -- generation of a primary key number via a corresponding sequence.
137 -- It is important to note that any 3rd party maintenance should be reviewed
138 -- before placing in this procedure.
139 --
140 -- Access Status:
141 -- Internal Row Handler Use Only.
142 --
143 -- {End Of Comments}
144 -- ----------------------------------------------------------------------------
145 Procedure pre_insert(p_rec in out nocopy ben_bbp_shd.g_rec_type) is
146 --
147 l_proc varchar2(72) := g_package||'pre_insert';
148 --
149 --
150 --
151 Begin
152 hr_utility.set_location('Entering:'||l_proc, 5);
153 --
154 select ben_batch_parameter_s.nextval
155 into p_rec.batch_parameter_id
156 from sys.dual;
157 --
158 --
159 hr_utility.set_location(' Leaving:'||l_proc, 10);
160 End pre_insert;
161 --
162 -- ----------------------------------------------------------------------------
163 -- |-----------------------------< post_insert >------------------------------|
164 -- ----------------------------------------------------------------------------
165 -- {Start Of Comments}
166 --
167 -- Description:
168 -- This private procedure contains any processing which is required after the
169 -- insert dml.
170 --
171 -- Prerequisites:
172 -- This is an internal procedure which is called from the ins procedure.
173 --
174 -- In Parameters:
175 -- A Pl/Sql record structre.
176 --
177 -- Post Success:
178 -- Processing continues.
179 --
180 -- Post Failure:
181 -- If an error has occurred, an error message and exception will be raised
182 -- but not handled.
183 --
184 -- Developer Implementation Notes:
185 -- Any post-processing required after the insert dml is issued should be
186 -- coded within this procedure. It is important to note that any 3rd party
187 -- maintenance should be reviewed before placing in this procedure.
188 --
189 -- Access Status:
190 -- Internal Row Handler Use Only.
191 --
192 -- {End Of Comments}
193 -- ----------------------------------------------------------------------------
194 Procedure post_insert(p_effective_date in date,
195 p_rec in ben_bbp_shd.g_rec_type) is
196 --
197 l_proc varchar2(72) := g_package||'post_insert';
198 --
199 Begin
200 hr_utility.set_location('Entering:'||l_proc, 5);
201 --
202 --
203 -- Start of API User Hook for post_insert.
204 --
205 begin
206 --
207 ben_bbp_rki.after_insert
208 (p_batch_parameter_id =>p_rec.batch_parameter_id
209 ,p_batch_exe_cd =>p_rec.batch_exe_cd
210 ,p_thread_cnt_num =>p_rec.thread_cnt_num
211 ,p_max_err_num =>p_rec.max_err_num
212 ,p_chunk_size =>p_rec.chunk_size
213 ,p_business_group_id =>p_rec.business_group_id
214 ,p_object_version_number =>p_rec.object_version_number
215 ,p_effective_date =>p_effective_date);
216 --
217 exception
218 --
219 when hr_api.cannot_find_prog_unit then
220 --
221 hr_api.cannot_find_prog_unit_error
222 (p_module_name => 'ben_batch_parameter'
223 ,p_hook_type => 'AI');
224 --
225 end;
226 --
227 -- End of API User Hook for post_insert.
228 --
229 --
230 hr_utility.set_location(' Leaving:'||l_proc, 10);
231 End post_insert;
232 --
233 -- ----------------------------------------------------------------------------
234 -- |---------------------------------< ins >----------------------------------|
235 -- ----------------------------------------------------------------------------
236 Procedure ins
237 (p_effective_date in date,
238 p_rec in out nocopy ben_bbp_shd.g_rec_type) is
239 --
240 l_proc varchar2(72) := g_package||'ins';
241 --
242 Begin
243 hr_utility.set_location('Entering:'||l_proc, 5);
244 --
245 -- Call the supporting insert validate operations
246 --
247 ben_bbp_bus.insert_validate(p_rec,p_effective_date);
248 --
249 -- Call the supporting pre-insert operation
250 --
251 pre_insert(p_rec);
252 --
253 -- Insert the row
254 --
255 insert_dml(p_rec);
256 --
257 -- Call the supporting post-insert operation
258 --
259 post_insert(p_effective_date,p_rec);
260 --
261 end ins;
262 --
263 -- ----------------------------------------------------------------------------
264 -- |---------------------------------< ins >----------------------------------|
265 -- ----------------------------------------------------------------------------
266 Procedure ins
267 ( p_effective_date in date,
268 p_batch_parameter_id out nocopy number,
269 p_batch_exe_cd in varchar2 default null,
270 p_thread_cnt_num in number default null,
271 p_max_err_num in number default null,
272 p_chunk_size in number default null,
273 p_business_group_id in number,
274 p_object_version_number out nocopy number
275 ) is
276 --
277 l_rec ben_bbp_shd.g_rec_type;
278 l_proc varchar2(72) := g_package||'ins';
279 --
280 Begin
281 hr_utility.set_location('Entering:'||l_proc, 5);
282 --
283 -- Call conversion function to turn arguments into the
284 -- p_rec structure.
285 --
286 l_rec :=
287 ben_bbp_shd.convert_args
288 (
289 null,
290 p_batch_exe_cd,
291 p_thread_cnt_num,
292 p_max_err_num,
293 p_chunk_size,
294 p_business_group_id,
295 null
296 );
297 --
298 -- Having converted the arguments into the ben_bbp_rec
299 -- plsql record structure we call the corresponding record business process.
300 --
301 ins(p_effective_date,l_rec);
302 --
303 -- As the primary key argument(s)
304 -- are specified as an OUT's we must set these values.
305 --
306 p_batch_parameter_id := l_rec.batch_parameter_id;
307 p_object_version_number := l_rec.object_version_number;
308 --
309 hr_utility.set_location(' Leaving:'||l_proc, 10);
310 End ins;
311 --
312 end ben_bbp_ins;