1 Package Body pay_pta_ins as
2 /* $Header: pyptarhi.pkb 120.0 2005/05/29 07:56:20 appldev noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- | Private Global Definitions |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package varchar2(33) := ' pay_pta_ins.'; -- Global package name
9 --
10 -- ----------------------------------------------------------------------------
11 -- |------------------------------< insert_dml >------------------------------|
12 -- ----------------------------------------------------------------------------
13 -- {Start Of Comments}
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 -- {End Of Comments}
52 -- ----------------------------------------------------------------------------
53 Procedure insert_dml
54 (p_rec in out nocopy pay_pta_shd.g_rec_type
55 ) is
56 --
57 l_proc varchar2(72) := g_package||'insert_dml';
58 --
59 Begin
60 hr_utility.set_location('Entering:'||l_proc, 5);
61 p_rec.object_version_number := 1; -- Initialise the object version
62 --
63 --
64 --
65 -- Insert the row into: pay_dated_tables
66 --
67 insert into pay_dated_tables
68 (dated_table_id
69 ,table_name
70 ,application_id
71 ,surrogate_key_name
72 ,start_date_name
73 ,end_date_name
74 ,business_group_id
75 ,legislation_code
76 ,object_version_number
77 ,dyn_trigger_type
78 ,dyn_trigger_package_name
79 ,dyn_trig_pkg_generated
80 )
81 Values
82 (p_rec.dated_table_id
83 ,p_rec.table_name
84 ,p_rec.application_id
85 ,p_rec.surrogate_key_name
86 ,p_rec.start_date_name
87 ,p_rec.end_date_name
88 ,p_rec.business_group_id
89 ,p_rec.legislation_code
90 ,p_rec.object_version_number
91 ,p_rec.dyn_trigger_type
92 ,p_rec.dyn_trigger_package_name
93 ,p_rec.dyn_trig_pkg_generated
94 );
95 --
96 --
97 --
98 hr_utility.set_location(' Leaving:'||l_proc, 10);
99 Exception
100 When hr_api.check_integrity_violated Then
101 -- A check constraint has been violated
102 --
103 pay_pta_shd.constraint_error
104 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105 When hr_api.parent_integrity_violated Then
106 -- Parent integrity has been violated
107 --
108 pay_pta_shd.constraint_error
109 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
110 When hr_api.unique_integrity_violated Then
111 -- Unique integrity has been violated
112 --
113 pay_pta_shd.constraint_error
114 (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
115 When Others Then
116 --
117 Raise;
118 End insert_dml;
119 --
120 -- ----------------------------------------------------------------------------
121 -- |------------------------------< pre_insert >------------------------------|
122 -- ----------------------------------------------------------------------------
123 -- {Start Of Comments}
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 -- {End Of Comments}
156 -- ----------------------------------------------------------------------------
157 Procedure pre_insert
158 (p_rec in out nocopy pay_pta_shd.g_rec_type
159 ) is
160 --
161 l_proc varchar2(72) := g_package||'pre_insert';
162 --
163 Cursor C_Sel1 is select pay_dated_tables_s.nextval from sys.dual;
164 --
165 Cursor C_Sel2 is select application_id
166 from fnd_tables where table_name = p_rec.table_name;
167 Begin
168 hr_utility.set_location('Entering:'||l_proc, 5);
169 --
170 --
171 -- Select the next sequence number
172 --
173 Open C_Sel1;
174 Fetch C_Sel1 Into p_rec.dated_table_id;
175 Close C_Sel1;
176 --
177 if p_rec.application_id is null then
178 Open C_Sel2;
179 Fetch C_Sel2 Into p_rec.application_id;
180 Close C_Sel2;
181 end if;
182 --
183 hr_utility.set_location(' Leaving:'||l_proc, 10);
184 End pre_insert;
185 --
186 -- ----------------------------------------------------------------------------
187 -- |-----------------------------< post_insert >------------------------------|
188 -- ----------------------------------------------------------------------------
189 -- {Start Of Comments}
190 --
191 -- Description:
192 -- This private procedure contains any processing which is required after the
193 -- insert dml.
194 --
195 -- Prerequisites:
196 -- This is an internal procedure which is called from the ins procedure.
197 --
198 -- In Parameters:
199 -- A Pl/Sql record structre.
200 --
201 -- Post Success:
202 -- Processing continues.
203 --
204 -- Post Failure:
205 -- If an error has occurred, an error message and exception will be raised
206 -- but not handled.
207 --
208 -- Developer Implementation Notes:
209 -- Any post-processing required after the insert dml is issued should be
210 -- coded within this procedure. It is important to note that any 3rd party
211 -- maintenance should be reviewed before placing in this procedure.
212 --
213 -- Access Status:
214 -- Internal Row Handler Use Only.
215 --
216 -- {End Of Comments}
217 -- ----------------------------------------------------------------------------
218 Procedure post_insert
219 (p_rec in pay_pta_shd.g_rec_type
220 ) is
221 --
222 l_proc varchar2(72) := g_package||'post_insert';
223 --
224 Begin
225 hr_utility.set_location('Entering:'||l_proc, 5);
226 begin
227 --
228 pay_pta_rki.after_insert
229 (p_dated_table_id
230 => p_rec.dated_table_id
231 ,p_table_name
232 => p_rec.table_name
233 ,p_application_id
234 => p_rec.application_id
235 ,p_surrogate_key_name
236 => p_rec.surrogate_key_name
237 ,p_start_date_name
238 => p_rec.start_date_name
239 ,p_end_date_name
240 => p_rec.end_date_name
241 ,p_business_group_id
242 => p_rec.business_group_id
243 ,p_legislation_code
244 => p_rec.legislation_code
245 ,p_object_version_number
246 => p_rec.object_version_number
247 ,p_dyn_trigger_type
248 => p_rec.dyn_trigger_type
249 ,p_dyn_trigger_package_name
250 => p_rec.dyn_trigger_package_name
251 ,p_dyn_trig_pkg_generated
252 => p_rec.dyn_trig_pkg_generated
253 );
254 --
255 exception
256 --
257 when hr_api.cannot_find_prog_unit then
258 --
259 hr_api.cannot_find_prog_unit_error
260 (p_module_name => 'PAY_DATED_TABLES'
261 ,p_hook_type => 'AI');
262 --
263 end;
264 --
265 hr_utility.set_location(' Leaving:'||l_proc, 10);
266 End post_insert;
267 --
268 -- ----------------------------------------------------------------------------
269 -- |---------------------------------< ins >----------------------------------|
270 -- ----------------------------------------------------------------------------
271 Procedure ins
272 (p_rec in out nocopy pay_pta_shd.g_rec_type
273 ) is
274 --
275 l_proc varchar2(72) := g_package||'ins';
276 --
277 Begin
278 hr_utility.set_location('Entering:'||l_proc, 5);
279 --
280 -- Call the supporting insert validate operations
281 --
282 pay_pta_bus.insert_validate
283 (p_rec
284 );
285 --
286 -- Call the supporting pre-insert operation
287 --
288 pay_pta_ins.pre_insert(p_rec);
289 --
290 -- Insert the row
291 --
292 pay_pta_ins.insert_dml(p_rec);
293 --
294 -- Call the supporting post-insert operation
295 --
296 pay_pta_ins.post_insert
297 (p_rec
298 );
299 --
300 hr_utility.set_location('Leaving:'||l_proc, 20);
301 end ins;
302 --
303 -- ----------------------------------------------------------------------------
304 -- |---------------------------------< ins >----------------------------------|
305 -- ----------------------------------------------------------------------------
306 Procedure ins
307 (p_table_name in varchar2
308 ,p_application_id in number default null
309 ,p_surrogate_key_name in varchar2
310 ,p_start_date_name in varchar2
311 ,p_end_date_name in varchar2
312 ,p_business_group_id in number default null
313 ,p_legislation_code in varchar2 default null
314 ,p_dated_table_id out nocopy number
315 ,p_object_version_number out nocopy number
316 ,p_dyn_trigger_type in varchar2 default null
317 ,p_dyn_trigger_package_name in varchar2 default null
318 ,p_dyn_trig_pkg_generated in varchar2 default null
319 ) is
320 --
321 l_rec pay_pta_shd.g_rec_type;
322 l_proc varchar2(72) := g_package||'ins';
323 --
324 Begin
325 hr_utility.set_location('Entering:'||l_proc, 5);
326 --
327 -- Call conversion function to turn arguments into the
328 -- p_rec structure.
329 --
330 l_rec :=
331 pay_pta_shd.convert_args
332 (null
333 ,p_table_name
334 ,p_application_id
335 ,p_surrogate_key_name
336 ,p_start_date_name
337 ,p_end_date_name
338 ,p_business_group_id
339 ,p_legislation_code
340 ,null
341 ,p_dyn_trigger_type
342 ,p_dyn_trigger_package_name
343 ,p_dyn_trig_pkg_generated
344 );
345 --
346 -- Having converted the arguments into the pay_pta_rec
347 -- plsql record structure we call the corresponding record business process.
348 --
349 pay_pta_ins.ins
350 (l_rec
351 );
352 --
353 -- As the primary key argument(s)
354 -- are specified as an OUT's we must set these values.
355 --
356 p_dated_table_id := l_rec.dated_table_id;
357 p_object_version_number := l_rec.object_version_number;
358 --
359 hr_utility.set_location(' Leaving:'||l_proc, 10);
360 End ins;
361 --
362 end pay_pta_ins;