DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_EVP_INS

Source


1 Package Body pay_evp_ins as
2 /* $Header: pyevprhi.pkb 115.5 2002/12/10 18:44:32 dsaxby noship $ */
3 --
4 -- ----------------------------------------------------------------------------
5 -- |                     Private Global Definitions                           |
6 -- ----------------------------------------------------------------------------
7 --
8 g_package  varchar2(33)	:= '  pay_evp_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_evp_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_event_procedures
66   --
67   insert into pay_event_procedures
68       (event_procedure_id
69       ,dated_table_id
70       ,procedure_name
71       ,business_group_id
72       ,legislation_code
73       ,column_name
74       ,object_version_number
75       )
76   Values
77     (p_rec.event_procedure_id
78     ,p_rec.dated_table_id
79     ,p_rec.procedure_name
80     ,p_rec.business_group_id
81     ,p_rec.legislation_code
82     ,p_rec.column_name
83     ,p_rec.object_version_number
84     );
85   --
86   --
87   --
88   hr_utility.set_location(' Leaving:'||l_proc, 10);
89 Exception
90   When hr_api.check_integrity_violated Then
91     -- A check constraint has been violated
92     --
93     pay_evp_shd.constraint_error
94       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
95   When hr_api.parent_integrity_violated Then
96     -- Parent integrity has been violated
97     --
98     pay_evp_shd.constraint_error
99       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
100   When hr_api.unique_integrity_violated Then
101     -- Unique integrity has been violated
102     --
103     pay_evp_shd.constraint_error
104       (p_constraint_name => hr_api.strip_constraint_name(SQLERRM));
105   When Others Then
106     --
107     Raise;
108 End insert_dml;
109 --
110 -- ----------------------------------------------------------------------------
111 -- |------------------------------< pre_insert >------------------------------|
112 -- ----------------------------------------------------------------------------
113 -- {Start Of Comments}
114 --
115 -- Description:
116 --   This private procedure contains any processing which is required before
117 --   the insert dml. Presently, if the entity has a corresponding primary
118 --   key which is maintained by an associating sequence, the primary key for
119 --   the entity will be populated with the next sequence value in
120 --   preparation for the insert dml.
121 --
122 -- Prerequisites:
123 --   This is an internal procedure which is called from the ins procedure.
124 --
125 -- In Parameters:
126 --   A Pl/Sql record structre.
127 --
128 -- Post Success:
129 --   Processing continues.
130 --
131 -- Post Failure:
132 --   If an error has occurred, an error message and exception will be raised
133 --   but not handled.
134 --
135 -- Developer Implementation Notes:
136 --   Any pre-processing required before the insert dml is issued should be
137 --   coded within this procedure. As stated above, a good example is the
138 --   generation of a primary key number via a corresponding sequence.
139 --   It is important to note that any 3rd party maintenance should be reviewed
140 --   before placing in this procedure.
141 --
142 -- Access Status:
143 --   Internal Row Handler Use Only.
144 --
145 -- {End Of Comments}
146 -- ----------------------------------------------------------------------------
147 Procedure pre_insert
148   (p_rec  in out nocopy pay_evp_shd.g_rec_type
149   ) is
150 --
151   l_proc  varchar2(72) := g_package||'pre_insert';
152 --
153   Cursor C_Sel1 is select pay_event_procedures_s.nextval from sys.dual;
154 --
155 Begin
156   hr_utility.set_location('Entering:'||l_proc, 5);
157   --
158   --
159   -- Select the next sequence number
160   --
161   Open C_Sel1;
162   Fetch C_Sel1 Into p_rec.event_procedure_id;
163   Close C_Sel1;
164   --
165   hr_utility.set_location(' Leaving:'||l_proc, 10);
166 End pre_insert;
167 --
168 -- ----------------------------------------------------------------------------
169 -- |-----------------------------< post_insert >------------------------------|
170 -- ----------------------------------------------------------------------------
171 -- {Start Of Comments}
172 --
173 -- Description:
174 --   This private procedure contains any processing which is required after the
175 --   insert dml.
176 --
177 -- Prerequisites:
178 --   This is an internal procedure which is called from the ins procedure.
179 --
180 -- In Parameters:
181 --   A Pl/Sql record structre.
182 --
183 -- Post Success:
184 --   Processing continues.
185 --
186 -- Post Failure:
187 --   If an error has occurred, an error message and exception will be raised
188 --   but not handled.
189 --
190 -- Developer Implementation Notes:
191 --   Any post-processing required after the insert dml is issued should be
192 --   coded within this procedure. It is important to note that any 3rd party
193 --   maintenance should be reviewed before placing in this procedure.
194 --
195 -- Access Status:
196 --   Internal Row Handler Use Only.
197 --
198 -- {End Of Comments}
199 -- ----------------------------------------------------------------------------
200 Procedure post_insert
201   (p_rec                          in pay_evp_shd.g_rec_type
202   ) is
203 --
204   l_proc  varchar2(72) := g_package||'post_insert';
205 --
206 Begin
207   hr_utility.set_location('Entering:'||l_proc, 5);
208   begin
209     --
210     pay_evp_rki.after_insert
211       (p_event_procedure_id
212       => p_rec.event_procedure_id
213       ,p_dated_table_id
214       => p_rec.dated_table_id
215       ,p_procedure_name
216       => p_rec.procedure_name
217       ,p_business_group_id
218       => p_rec.business_group_id
219       ,p_legislation_code
220       => p_rec.legislation_code
221       ,p_column_name
222       => p_rec.column_name
223       ,p_object_version_number
224       => p_rec.object_version_number
225       );
226     --
227   exception
228     --
229     when hr_api.cannot_find_prog_unit then
230       --
231       hr_api.cannot_find_prog_unit_error
232         (p_module_name => 'PAY_EVENT_PROCEDURES'
233         ,p_hook_type   => 'AI');
234       --
235   end;
236   --
237   hr_utility.set_location(' Leaving:'||l_proc, 10);
238 End post_insert;
239 --
240 -- ----------------------------------------------------------------------------
241 -- |---------------------------------< ins >----------------------------------|
242 -- ----------------------------------------------------------------------------
243 Procedure ins
244   (p_rec                          in out nocopy pay_evp_shd.g_rec_type
245   ) is
246 --
247   l_proc  varchar2(72) := g_package||'ins';
248 --
249 Begin
250   hr_utility.set_location('Entering:'||l_proc, 5);
251   --
252   -- Call the supporting insert validate operations
253   --
254   pay_evp_bus.insert_validate
255      (p_rec
256      );
257   --
258   -- Call the supporting pre-insert operation
259   --
260   pay_evp_ins.pre_insert(p_rec);
261   --
262   -- Insert the row
263   --
264   pay_evp_ins.insert_dml(p_rec);
265   --
266   -- Call the supporting post-insert operation
267   --
268   pay_evp_ins.post_insert
269      (p_rec
270      );
271   --
272   hr_utility.set_location('Leaving:'||l_proc, 20);
273 end ins;
274 --
275 -- ----------------------------------------------------------------------------
276 -- |---------------------------------< ins >----------------------------------|
277 -- ----------------------------------------------------------------------------
278 Procedure ins
279   (p_dated_table_id                 in     number
280   ,p_procedure_name                 in     varchar2 default null
281   ,p_business_group_id              in     number   default null
282   ,p_legislation_code               in     varchar2 default null
283   ,p_column_name                    in     varchar2 default null
284   ,p_event_procedure_id                out nocopy number
285   ,p_object_version_number             out nocopy number
286   ) is
287 --
288   l_rec	  pay_evp_shd.g_rec_type;
289   l_proc  varchar2(72) := g_package||'ins';
290 --
291 Begin
292   hr_utility.set_location('Entering:'||l_proc, 5);
293   --
294   -- Call conversion function to turn arguments into the
295   -- p_rec structure.
296   --
297   l_rec :=
298   pay_evp_shd.convert_args
299     (null
300     ,p_dated_table_id
301     ,p_procedure_name
302     ,p_business_group_id
303     ,p_legislation_code
304     ,p_column_name
305     ,null
306     );
307   --
308   -- Having converted the arguments into the pay_evp_rec
309   -- plsql record structure we call the corresponding record business process.
310   --
311   pay_evp_ins.ins
312      (l_rec
313      );
314   --
315   -- As the primary key argument(s)
316   -- are specified as an OUT's we must set these values.
317   --
318   p_event_procedure_id := l_rec.event_procedure_id;
319   p_object_version_number := l_rec.object_version_number;
320   --
321   hr_utility.set_location(' Leaving:'||l_proc, 10);
322 End ins;
323 --
324 end pay_evp_ins;