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