DBA Data[Home] [Help]

PACKAGE BODY: APPS.PAY_PWO_INS

Source


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