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