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