1 Package Body hxc_aps_ins as
2 /* $Header: hxcaprpsrhi.pkb 120.2 2005/09/23 10:38:57 sechandr noship $ */
3 --
4 -- ----------------------------------------------------------------------------
8 g_package varchar2(33) := ' hxc_aps_ins.'; -- Global package name
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
9 g_debug boolean := hr_utility.debug_enabled;
10 --
11 -- ----------------------------------------------------------------------------
12 -- |------------------------------< insert_dml >------------------------------|
13 -- ----------------------------------------------------------------------------
14 -- {Start Of Comments}
15 --
16 -- Description:
17 -- This procedure controls the actual dml insert logic. The processing of
18 -- this procedure are as follows:
19 -- 1) Initialise the object_version_number to 1 if the object_version_number
20 -- is defined as an attribute for this entity.
21 -- 2) To set and unset the g_api_dml status as required (as we are about to
22 -- perform dml).
23 -- 3) To insert the row into the schema.
24 -- 4) To trap any constraint violations that may have occurred.
25 -- 5) To raise any other errors.
26 --
27 -- Prerequisites:
28 -- This is an internal private procedure which must be called from the ins
29 -- procedure and must have all mandatory attributes set (except the
30 -- object_version_number which is initialised within this procedure).
31 --
32 -- In Parameters:
33 -- A Pl/Sql record structre.
34 --
35 -- Post Success:
36 -- The specified row will be inserted into the schema.
37 --
38 -- Post Failure:
39 -- On the insert dml failure it is important to note that we always reset the
40 -- g_api_dml status to false.
41 -- If a check, unique or parent integrity constraint violation is raised the
42 -- constraint_error procedure will be called.
43 -- If any other error is reported, the error will be raised after the
44 -- g_api_dml status is reset.
45 --
46 -- Developer Implementation Notes:
47 -- None.
48 --
49 -- Access Status:
50 -- Internal Row Handler Use Only.
51 --
52 -- {End Of Comments}
53 -- ----------------------------------------------------------------------------
54 Procedure insert_dml
55 (p_rec in out nocopy hxc_aps_shd.g_rec_type
56 ) is
57 --
58 l_proc varchar2(72);
59 --
60 Begin
61 if g_debug then
62 l_proc:= g_package||'insert_dml';
63 hr_utility.set_location('Entering:'||l_proc, 5);
64 end if;
65 p_rec.object_version_number := 1; -- Initialise the object version
66 --
67 hxc_aps_shd.g_api_dml := true; -- Set the api dml status
68 --
69 -- Insert the row into: hxc_approval_period_sets
70 --
71 insert into hxc_approval_period_sets
72 (approval_period_set_id
73 ,name
74 ,object_version_number
75 ,creation_date
76 ,created_by
77 ,last_updated_by
78 ,last_update_date
79 ,last_update_login
80 )
81 Values
82 (p_rec.approval_period_set_id
83 ,p_rec.name
84 ,p_rec.object_version_number
85 ,sysdate
86 ,fnd_global.user_id
87 ,fnd_global.user_id
88 ,sysdate
89 ,fnd_global.login_id
90 );
91 --
92 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
93 --
94 if g_debug then
95 hr_utility.set_location(' Leaving:'||l_proc, 10);
96 end if;
97 Exception
98 When hr_api.check_integrity_violated Then
99 -- A check constraint has been violated
100 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
101 hxc_aps_shd.constraint_error
102 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
103 When hr_api.parent_integrity_violated Then
104 -- Parent integrity has been violated
105 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
106 hxc_aps_shd.constraint_error
107 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
108 When hr_api.unique_integrity_violated Then
109 -- Unique integrity has been violated
110 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
111 hxc_aps_shd.constraint_error
112 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
113 When Others Then
114 hxc_aps_shd.g_api_dml := false; -- Unset the api dml status
115 Raise;
116 End insert_dml;
117 --
118 -- ----------------------------------------------------------------------------
119 -- |------------------------------< pre_insert >------------------------------|
120 -- ----------------------------------------------------------------------------
121 -- {Start Of Comments}
122 --
123 -- Description:
124 -- This private procedure contains any processing which is required before
125 -- the insert dml. Presently, if the entity has a corresponding primary
126 -- key which is maintained by an associating sequence, the primary key for
127 -- the entity will be populated with the next sequence value in
128 -- preparation for the insert dml.
129 --
130 -- Prerequisites:
131 -- This is an internal procedure which is called from the ins procedure.
132 --
133 -- In Parameters:
134 -- A Pl/Sql record structre.
135 --
136 -- Post Success:
137 -- Processing continues.
138 --
139 -- Post Failure:
140 -- If an error has occurred, an error message and exception will be raised
141 -- but not handled.
142 --
143 -- Developer Implementation Notes:
144 -- Any pre-processing required before the insert dml is issued should be
145 -- coded within this procedure. As stated above, a good example is the
149 --
146 -- generation of a primary key number via a corresponding sequence.
147 -- It is important to note that any 3rd party maintenance should be reviewed
148 -- before placing in this procedure.
150 -- Access Status:
151 -- Internal Row Handler Use Only.
152 --
153 -- {End Of Comments}
154 -- ----------------------------------------------------------------------------
155 Procedure pre_insert
156 (p_rec in out nocopy hxc_aps_shd.g_rec_type
157 ) is
158 --
159 l_proc varchar2(72);
160 --
161 Cursor C_Sel1 is select hxc_approval_period_sets_s.nextval from sys.dual;
162 --
163 Begin
164 if g_debug then
165 l_proc:= g_package||'pre_insert';
166 hr_utility.set_location('Entering:'||l_proc, 5);
167 end if;
168 --
169 --
170 -- Select the next sequence number
171 --
172 Open C_Sel1;
173 Fetch C_Sel1 Into p_rec.approval_period_set_id;
174 Close C_Sel1;
175 --
176 if g_debug then
177 hr_utility.set_location(' Leaving:'||l_proc, 10);
178 end if;
179 End pre_insert;
180 --
181 -- ----------------------------------------------------------------------------
182 -- |-----------------------------< post_insert >------------------------------|
183 -- ----------------------------------------------------------------------------
184 -- {Start Of Comments}
185 --
186 -- Description:
187 -- This private procedure contains any processing which is required after the
188 -- insert dml.
189 --
190 -- Prerequisites:
191 -- This is an internal procedure which is called from the ins procedure.
192 --
193 -- In Parameters:
194 -- A Pl/Sql record structre.
195 --
196 -- Post Success:
197 -- Processing continues.
198 --
199 -- Post Failure:
200 -- If an error has occurred, an error message and exception will be raised
201 -- but not handled.
202 --
203 -- Developer Implementation Notes:
204 -- Any post-processing required after the insert dml is issued should be
205 -- coded within this procedure. It is important to note that any 3rd party
206 -- maintenance should be reviewed before placing in this procedure.
207 --
208 -- Access Status:
209 -- Internal Row Handler Use Only.
210 --
211 -- {End Of Comments}
212 -- ----------------------------------------------------------------------------
213 Procedure post_insert
214 (p_rec in hxc_aps_shd.g_rec_type
215 ) is
216 --
217 l_proc varchar2(72);
218 --
219 Begin
220 g_debug:=hr_utility.debug_enabled;
221 if g_debug then
222 l_proc:= g_package||'post_insert';
223 hr_utility.set_location('Entering:'||l_proc, 5);
224 end if;
225 begin
226 --
227 hxc_aps_rki.after_insert
228 (p_approval_period_set_id
229 => p_rec.approval_period_set_id
230 ,p_name
231 => p_rec.name
232 ,p_object_version_number
233 => p_rec.object_version_number
234 );
235 --
236 exception
237 --
238 when hr_api.cannot_find_prog_unit then
239 --
240 hr_api.cannot_find_prog_unit_error
241 (p_module_name => 'HXC_APPROVAL_PERIOD_SETS'
242 ,p_hook_type => 'AI');
243 --
244 end;
245 --
246 if g_debug then
247 hr_utility.set_location(' Leaving:'||l_proc, 10);
248 end if;
249 End post_insert;
250 --
251 -- ----------------------------------------------------------------------------
252 -- |---------------------------------< ins >----------------------------------|
253 -- ----------------------------------------------------------------------------
254 Procedure ins
255 (p_rec in out nocopy hxc_aps_shd.g_rec_type
256 ) is
257 --
258 l_proc varchar2(72);
259 --
260 Begin
261 g_debug:=hr_utility.debug_enabled;
262 if g_debug then
263 l_proc:= g_package||'ins';
264 hr_utility.set_location('Entering:'||l_proc, 5);
265 end if;
266 --
267 -- Call the supporting insert validate operations
268 --
269 hxc_aps_bus.insert_validate
270 (p_rec
271 );
272 --
273 -- Call the supporting pre-insert operation
274 --
275 hxc_aps_ins.pre_insert(p_rec);
276 --
277 -- Insert the row
278 --
279 hxc_aps_ins.insert_dml(p_rec);
280 --
281 -- Call the supporting post-insert operation
282 --
283 hxc_aps_ins.post_insert
284 (p_rec
285 );
286 --
287 if g_debug then
288 hr_utility.set_location('Leaving:'||l_proc, 20);
289 end if;
290 end ins;
291 --
292 -- ----------------------------------------------------------------------------
293 -- |---------------------------------< ins >----------------------------------|
294 -- ----------------------------------------------------------------------------
295 Procedure ins
296 (p_name in varchar2
297 ,p_approval_period_set_id out nocopy number
298 ,p_object_version_number out nocopy number
299 ) is
300 --
301 l_rec hxc_aps_shd.g_rec_type;
302 l_proc varchar2(72);
303 --
304 Begin
305 g_debug:=hr_utility.debug_enabled;
306 if g_debug then
307 l_proc := g_package||'ins';
308 hr_utility.set_location('Entering:'||l_proc, 5);
309 end if;
310 --
311 -- Call conversion function to turn arguments into the
312 -- p_rec structure.
313 --
314 l_rec :=
315 hxc_aps_shd.convert_args
316 (null
317 ,p_name
318 ,null
319 );
320 --
321 -- Having converted the arguments into the hxc_aps_rec
322 -- plsql record structure we call the corresponding record business process.
323 --
324 hxc_aps_ins.ins
325 (l_rec
326 );
327 --
328 -- As the primary key argument(s)
329 -- are specified as an OUT's we must set these values.
330 --
331 p_approval_period_set_id := l_rec.approval_period_set_id;
332 p_object_version_number := l_rec.object_version_number;
333 --
334 if g_debug then
335 hr_utility.set_location(' Leaving:'||l_proc, 10);
336 end if;
337 End ins;
338 --
339 end hxc_aps_ins;