1 Package Body hxc_had_ins as
2 /* $Header: hxchadrhi.pkb 120.2.12020000.2 2012/08/27 06:36:28 pravesk ship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' hxc_had_ins.'; -- Global package name
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_had_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 --
68 --
69 -- Insert the row into: hxc_alias_definitions
70 --
71 insert into hxc_alias_definitions
72 (alias_definition_id
73 ,description
74 ,alias_definition_name
75 ,alias_context_code
76 ,business_group_id
77 ,legislation_code
78 ,timecard_field
79 ,object_version_number
80 ,alias_type_id
81 ,creation_date
82 ,created_by
83 ,last_updated_by
84 ,last_update_date
85 ,last_update_login
86 )
87 Values
88 (p_rec.alias_definition_id
89 ,p_rec.description
90 ,p_rec.alias_definition_name
91 ,p_rec.alias_context_code
92 ,p_rec.business_group_id
93 ,p_rec.legislation_code
94 ,p_rec.timecard_field
95 ,p_rec.object_version_number
96 ,p_rec.alias_type_id
97 ,sysdate
98 ,fnd_global.user_id
99 ,fnd_global.user_id
100 ,sysdate
101 ,fnd_global.login_id
102 );
103 --
104 --
105 --
106 if g_debug then
107 hr_utility.set_location(' Leaving:'||l_proc, 10);
108 end if;
109 Exception
110 When hr_api.check_integrity_violated Then
111 -- A check constraint has been violated
112 --
113 hxc_had_shd.constraint_error
114 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115 When hr_api.parent_integrity_violated Then
116 -- Parent integrity has been violated
117 --
118 hxc_had_shd.constraint_error
119 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
120 When hr_api.unique_integrity_violated Then
121 -- Unique integrity has been violated
122 --
123 hxc_had_shd.constraint_error
124 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
125 When Others Then
126 --
127 Raise;
128 End insert_dml;
129 --
130 -- ----------------------------------------------------------------------------
131 -- |------------------------------< pre_insert >------------------------------|
132 -- ----------------------------------------------------------------------------
133 -- {Start Of Comments}
134 --
135 -- Description:
136 -- This private procedure contains any processing which is required before
137 -- the insert dml. Presently, if the entity has a corresponding primary
138 -- key which is maintained by an associating sequence, the primary key for
139 -- the entity will be populated with the next sequence value in
140 -- preparation for the insert dml.
141 --
142 -- Prerequisites:
143 -- This is an internal procedure which is called from the ins procedure.
144 --
145 -- In Parameters:
146 -- A Pl/Sql record structre.
147 --
148 -- Post Success:
149 -- Processing continues.
150 --
151 -- Post Failure:
152 -- If an error has occurred, an error message and exception will be raised
153 -- but not handled.
154 --
155 -- Developer Implementation Notes:
156 -- Any pre-processing required before the insert dml is issued should be
157 -- coded within this procedure. As stated above, a good example is the
158 -- generation of a primary key number via a corresponding sequence.
159 -- It is important to note that any 3rd party maintenance should be reviewed
160 -- before placing in this procedure.
161 --
162 -- Access Status:
163 -- Internal Row Handler Use Only.
164 --
165 -- {End Of Comments}
166 -- ----------------------------------------------------------------------------
167 Procedure pre_insert
168 (p_rec in out nocopy hxc_had_shd.g_rec_type
169 ) is
170 --
171 l_proc varchar2(72);
172 --
173 Cursor C_Sel1 is select hxc_alias_definitions_s.nextval from sys.dual;
174 --
175 Begin
176 if g_debug then
177 l_proc := g_package||'pre_insert';
178 hr_utility.set_location('Entering:'||l_proc, 5);
179 end if;
180 --
181 --
182 -- Select the next sequence number
183 --
184 Open C_Sel1;
185 Fetch C_Sel1 Into p_rec.alias_definition_id;
186 Close C_Sel1;
187 --
188 if g_debug then
189 hr_utility.set_location(' Leaving:'||l_proc, 10);
190 end if;
191 End pre_insert;
192 --
193 -- ----------------------------------------------------------------------------
194 -- |-----------------------------< post_insert >------------------------------|
195 -- ----------------------------------------------------------------------------
196 -- {Start Of Comments}
197 --
198 -- Description:
199 -- This private procedure contains any processing which is required after the
200 -- insert dml.
201 --
202 -- Prerequisites:
203 -- This is an internal procedure which is called from the ins procedure.
204 --
205 -- In Parameters:
206 -- A Pl/Sql record structre.
207 --
208 -- Post Success:
209 -- Processing continues.
210 --
211 -- Post Failure:
212 -- If an error has occurred, an error message and exception will be raised
213 -- but not handled.
214 --
215 -- Developer Implementation Notes:
216 -- Any post-processing required after the insert dml is issued should be
217 -- coded within this procedure. It is important to note that any 3rd party
218 -- maintenance should be reviewed before placing in this procedure.
219 --
220 -- Access Status:
221 -- Internal Row Handler Use Only.
222 --
223 -- {End Of Comments}
224 -- ----------------------------------------------------------------------------
225 Procedure post_insert
226 (p_rec in hxc_had_shd.g_rec_type
227 ) is
228 --
229 l_proc varchar2(72);
230 --
231 Begin
232 if g_debug then
233 l_proc := g_package||'post_insert';
234 hr_utility.set_location('Entering:'||l_proc, 5);
235 end if;
236 begin
237 --
238 hxc_had_rki.after_insert
239 (p_alias_definition_id
240 => p_rec.alias_definition_id
241 ,p_description
242 => p_rec.description
243 ,p_alias_definition_name
244 => p_rec.alias_definition_name
245 ,p_alias_context_code
246 => p_rec.alias_context_code
247 ,p_business_group_id => p_rec.business_group_id
248 ,p_legislation_code => p_rec.legislation_code
249 ,p_timecard_field
250 => p_rec.timecard_field
251 ,p_object_version_number
252 => p_rec.object_version_number
253 ,p_alias_type_id
254 => p_rec.alias_type_id
255 );
256 --
257 exception
258 --
259 when hr_api.cannot_find_prog_unit then
260 --
261 hr_api.cannot_find_prog_unit_error
262 (p_module_name => 'HXC_ALIAS_DEFINITIONS'
263 ,p_hook_type => 'AI');
264 --
265 end;
266 --
267 if g_debug then
268 hr_utility.set_location(' Leaving:'||l_proc, 10);
269 end if;
270 End post_insert;
271 --
272 -- ----------------------------------------------------------------------------
273 -- |---------------------------------< ins >----------------------------------|
274 -- ----------------------------------------------------------------------------
275 Procedure ins
276 (p_rec in out nocopy hxc_had_shd.g_rec_type
277 ) is
278 --
279 l_proc varchar2(72);
280 --
281 Begin
282 g_debug:=hr_utility.debug_enabled;
283 if g_debug then
284 l_proc := g_package||'ins';
285 hr_utility.set_location('Entering:'||l_proc, 5);
286 end if;
287 --
288 -- Call the supporting insert validate operations
289 --
290 hxc_had_bus.insert_validate
291 (p_rec
292 );
293 --
294 -- Call the supporting pre-insert operation
295 --
296 hxc_had_ins.pre_insert(p_rec);
297 --
298 -- Insert the row
299 --
300 hxc_had_ins.insert_dml(p_rec);
301 --
302 -- Call the supporting post-insert operation
303 --
304 hxc_had_ins.post_insert
305 (p_rec
306 );
307 --
308 if g_debug then
309 hr_utility.set_location('Leaving:'||l_proc, 20);
310 end if;
311 end ins;
312 --
313 -- ----------------------------------------------------------------------------
314 -- |---------------------------------< ins >----------------------------------|
315 -- ----------------------------------------------------------------------------
316 Procedure ins
317 (p_alias_definition_name in varchar2
318 ,p_alias_context_code in varchar2 default null
319 ,p_business_group_id in number default null
320 ,p_legislation_code in varchar2 default null
321 ,p_timecard_field in varchar2
322 ,p_description in varchar2 default null
323 ,p_prompt in varchar2 default null
324 ,p_alias_definition_id out nocopy number
325 ,p_object_version_number out nocopy number
326 ,p_alias_type_id in number
327 ) is
328 --
329 l_rec hxc_had_shd.g_rec_type;
330 l_proc varchar2(72);
331 --
332 Begin
333 g_debug:=hr_utility.debug_enabled;
334 if g_debug then
335 l_proc := g_package||'ins';
336 hr_utility.set_location('Entering:'||l_proc, 5);
337 end if;
338 --
339 -- Call conversion function to turn arguments into the
340 -- p_rec structure.
341 --
342 l_rec :=
343 hxc_had_shd.convert_args
344 (null
345 ,p_description
346 ,p_alias_definition_name
347 ,p_alias_context_code
348 ,p_business_group_id
349 ,p_legislation_code
350 ,p_timecard_field
351 ,null
352 ,p_alias_type_id
353 );
354 --
355 -- Having converted the arguments into the hxc_had_rec
356 -- plsql record structure we call the corresponding record business process.
357 --
358 hxc_had_ins.ins
359 (l_rec
360 );
361 --
362 -- As the primary key argument(s)
363 -- are specified as an OUT's we must set these values.
364 --
365 p_alias_definition_id := l_rec.alias_definition_id;
366 p_object_version_number := l_rec.object_version_number;
367 --
368 -- Call row handler to insert into translated tables
369 --
370 hxc_dtl_ins.ins_tl
371 (p_language_code => USERENV('LANG')
372 ,p_alias_definition_id => p_alias_definition_id
373 ,p_alias_definition_name => p_alias_definition_name
374 ,p_description => p_description
375 ,p_prompt => p_prompt
376 );
377
378 if g_debug then
379 hr_utility.set_location(' Leaving:'||l_proc, 10);
380 end if;
381 End ins;
382 --
383 end hxc_had_ins;